diff options
author | Björn Schießle <bjoern@schiessle.org> | 2013-10-04 04:06:37 -0700 |
---|---|---|
committer | Björn Schießle <bjoern@schiessle.org> | 2013-10-04 04:06:37 -0700 |
commit | 31d5565a18d151ef1518789a5e80520efa4719cd (patch) | |
tree | 7d2da02957552a8ac49eb6f2f3bd6b08e1049406 /lib | |
parent | 514d7a884a5211fe246487421ea8103202d004d7 (diff) | |
parent | 51295e9a6b9cd8e351132e988858b5d4bd223968 (diff) | |
download | nextcloud-server-31d5565a18d151ef1518789a5e80520efa4719cd.tar.gz nextcloud-server-31d5565a18d151ef1518789a5e80520efa4719cd.zip |
Merge pull request #4689 from owncloud/sharing_mail_notification_master
send mail notification if a file was shared to a user/group
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/defaults.php | 5 | ||||
-rwxr-xr-x | lib/private/util.php | 2 | ||||
-rw-r--r-- | lib/public/share.php | 90 |
3 files changed, 85 insertions, 12 deletions
diff --git a/lib/private/defaults.php b/lib/private/defaults.php index 10813a3e8d8..4951c6f50ae 100644 --- a/lib/private/defaults.php +++ b/lib/private/defaults.php @@ -13,6 +13,7 @@ if (file_exists(OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults. class OC_Defaults { private $theme; + private $l; private $defaultEntity; private $defaultName; @@ -24,7 +25,7 @@ class OC_Defaults { private $defaultLogoClaim; function __construct() { - $l = OC_L10N::get('core'); + $this->l = OC_L10N::get('core'); $this->defaultEntity = "ownCloud"; /* e.g. company name, used for footers and copyright notices */ $this->defaultName = "ownCloud"; /* short name, used when referring to the software */ @@ -32,7 +33,7 @@ class OC_Defaults { $this->defaultBaseUrl = "http://owncloud.org"; $this->defaultSyncClientUrl = " http://owncloud.org/sync-clients/"; $this->defaultDocBaseUrl = "http://doc.owncloud.org"; - $this->defaultSlogan = $l->t("web services under your control"); + $this->defaultSlogan = $this->l->t("web services under your control"); $this->defaultLogoClaim = ""; if (class_exists("OC_Theme")) { diff --git a/lib/private/util.php b/lib/private/util.php index a4e9d07147e..ae9aef69b4c 100755 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -168,7 +168,7 @@ class OC_Util { OC_Util::loadVersion(); return \OC::$server->getSession()->get('OC_Channel'); } - + /** * @description get the build number of the current installed of ownCloud. * @return string diff --git a/lib/public/share.php b/lib/public/share.php index 6c5783f1179..e6a74117aa2 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -246,9 +246,9 @@ class Share { /** * @brief Get the item of item type shared with the current user - * @param string Item type - * @param string Item target - * @param int Format (optional) Format type must be defined by the backend + * @param string $itemType + * @param string $ItemTarget + * @param int $format (optional) Format type must be defined by the backend * @return Return depends on format */ public static function getItemSharedWith($itemType, $itemTarget, $format = self::FORMAT_NONE, @@ -258,6 +258,55 @@ class Share { } /** + * @brief Get the item of item type shared with a given user by source + * @param string $ItemType + * @param string $ItemSource + * @param string $user User user to whom the item was shared + * @return array Return list of items with file_target, permissions and expiration + */ + public static function getItemSharedWithUser($itemType, $itemSource, $user) { + + $shares = array(); + + // first check if there is a db entry for the specific user + $query = \OC_DB::prepare( + 'SELECT `file_target`, `permissions`, `expiration` + FROM + `*PREFIX*share` + WHERE + `item_source` = ? AND `item_type` = ? AND `share_with` = ?' + ); + + $result = \OC_DB::executeAudited($query, array($itemSource, $itemType, $user)); + + while ($row = $result->fetchRow()) { + $shares[] = $row; + } + + //if didn't found a result than let's look for a group share. + if(empty($shares)) { + $groups = \OC_Group::getUserGroups($user); + + $query = \OC_DB::prepare( + 'SELECT `file_target`, `permissions`, `expiration` + FROM + `*PREFIX*share` + WHERE + `item_source` = ? AND `item_type` = ? AND `share_with` in (?)' + ); + + $result = \OC_DB::executeAudited($query, array($itemSource, $itemType, implode(',', $groups))); + + while ($row = $result->fetchRow()) { + $shares[] = $row; + } + } + + return $shares; + + } + + /** * @brief Get the item of item type shared with the current user by source * @param string Item type * @param string Item source @@ -653,6 +702,29 @@ class Share { } return false; } + /** + * @brief sent status if users got informed by mail about share + * @param string $itemType + * @param string $itemSource + * @param int $shareType SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK + * @param bool $status + */ + public static function setSendMailStatus($itemType, $itemSource, $shareType, $status) { + $status = $status ? 1 : 0; + + $query = \OC_DB::prepare( + 'UPDATE `*PREFIX*share` + SET `mail_send` = ? + WHERE `item_type` = ? AND `item_source` = ? AND `share_type` = ?'); + + $result = $query->execute(array($status, $itemType, $itemSource, $shareType)); + + if($result === false) { + \OC_Log::write('OCP\Share', 'Couldn\'t set send mail status', \OC_Log::ERROR); + } + + + } /** * @brief Set the permissions of an item for a specific user or group @@ -983,19 +1055,19 @@ class Share { if ($format == self::FORMAT_STATUSES) { if ($itemType == 'file' || $itemType == 'folder') { $select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`,' - .' `share_type`, `file_source`, `path`, `expiration`, `storage`'; + .' `share_type`, `file_source`, `path`, `expiration`, `storage`, `mail_send`'; } else { - $select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `expiration`'; + $select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `expiration`, `mail_send`'; } } else { if (isset($uidOwner)) { if ($itemType == 'file' || $itemType == 'folder') { $select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`,' .' `share_type`, `share_with`, `file_source`, `path`, `permissions`, `stime`,' - .' `expiration`, `token`, `storage`'; + .' `expiration`, `token`, `storage`, `mail_send`'; } else { $select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `share_with`, `permissions`,' - .' `stime`, `file_source`, `expiration`, `token`'; + .' `stime`, `file_source`, `expiration`, `token`, `mail_send`'; } } else { if ($fileDependent) { @@ -1006,11 +1078,11 @@ class Share { $select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`, `uid_owner`, ' .'`share_type`, `share_with`, `file_source`, `path`, `file_target`, ' .'`permissions`, `expiration`, `storage`, `*PREFIX*filecache`.`parent` as `file_parent`, ' - .'`name`, `mtime`, `mimetype`, `mimepart`, `size`, `encrypted`, `etag`'; + .'`name`, `mtime`, `mimetype`, `mimepart`, `size`, `encrypted`, `etag`, `mail_send`'; } else { $select = '`*PREFIX*share`.`id`, `item_type`, `item_source`, `item_target`, `*PREFIX*share`.`parent`, `share_type`, `share_with`, `uid_owner`, - `file_source`, `path`, `file_target`, `permissions`, `stime`, `expiration`, `token`, `storage`'; + `file_source`, `path`, `file_target`, `permissions`, `stime`, `expiration`, `token`, `storage`, `mail_send`'; } } else { $select = '*'; |