summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/defaults.php31
-rw-r--r--lib/public/defaults.php19
-rw-r--r--lib/public/share.php81
-rwxr-xr-xlib/util.php16
4 files changed, 130 insertions, 17 deletions
diff --git a/lib/defaults.php b/lib/defaults.php
index 10813a3e8d8..26f417ae2ae 100644
--- a/lib/defaults.php
+++ b/lib/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")) {
@@ -47,6 +48,32 @@ class OC_Defaults {
return false;
}
+ /**
+ *
+ * @param string $itemType typically "file" or "folder"
+ */
+ public function getShareNotificationSubject($itemType) {
+ if ($this->themeExist('getShareNotificationSubject')) {
+ return $this->theme->getShareNotificationSubject($itemType);
+ } else {
+ return $this->l->t("A %s was shared with you", array($itemType));
+ }
+ }
+
+ /**
+ * @param string $sender owner of the file/folder
+ * @param string $itemName name of the file/folder
+ * @param string $itemType typically "file" or "folder"
+ * @param string $link link directly to the file/folder in your ownCloud
+ */
+ public function getShareNotificationText($sender, $itemName, $itemType, $link) {
+ if ($this->themeExist('getShareNotificationText')) {
+ return $this->theme->getShareNotificationText($sender, $itemName, $itemType, $link);
+ } else {
+ return $this->l->t("%s shared a %s called %s with you. You can find the %s here: %s", array($sender, $itemType, $itemName, $itemType, $link));
+ }
+ }
+
public function getBaseUrl() {
if ($this->themeExist('getBaseUrl')) {
return $this->theme->getBaseUrl();
diff --git a/lib/public/defaults.php b/lib/public/defaults.php
index 147f23e341f..9c8c3c0bdab 100644
--- a/lib/public/defaults.php
+++ b/lib/public/defaults.php
@@ -35,6 +35,25 @@ class Defaults {
}
/**
+ * @brief subject for notification mails if a new file was shared
+ * @param string $itemType typically "file" or "folder"
+ */
+ public function getShareNotificationSubject($itemType = "file") {
+ return $this->defaults->getShareNotificationSubject($itemType);
+ }
+
+ /**
+ * @brief mail body for notification mails if a new file was shared
+ * @param string $sender owner of the file/folder
+ * @param string $itemName name of the file/folder
+ * @param string $itemType typically "file" or "folder"
+ * @param string $link link directly to the file/folder in your ownCloud
+ */
+ public function getShareNotificationText($sender, $itemName, $itemType, $link) {
+ return $this->defaults->getShareNotificationText($sender, $itemName, $itemType, $link);
+ }
+
+ /**
* @breif get base URL for the organisation behind your ownCloud instance
* @return string
*/
diff --git a/lib/public/share.php b/lib/public/share.php
index b38208bc67f..eac6fab2b6a 100644
--- a/lib/public/share.php
+++ b/lib/public/share.php
@@ -106,22 +106,22 @@ class Share {
}
return false;
}
-
+
/**
* @brief Prepare a path to be passed to DB as file_target
* @return string Prepared path
*/
public static function prepFileTarget( $path ) {
-
+
// Paths in DB are stored with leading slashes, so add one if necessary
if ( substr( $path, 0, 1 ) !== '/' ) {
-
+
$path = '/' . $path;
-
+
}
-
+
return $path;
-
+
}
/**
@@ -251,7 +251,57 @@ class Share {
return self::getItems($itemType, $itemTarget, self::$shareTypeUserAndGroups, \OC_User::getUser(), null, $format,
$parameters, 1, $includeCollections);
}
-
+
+ /**
+ * @brief Get the item of item type shared with a given user by source
+ * @param string Item type
+ * @param string Item source
+ * @param string User user to whom the item was shared
+ * @return 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 = $query->execute(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 = $query->execute(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
@@ -633,6 +683,23 @@ 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` = ?');
+
+ $query->execute(array($status, $itemType, $itemSource, $shareType));
+ }
/**
* @brief Set the permissions of an item for a specific user or group
diff --git a/lib/util.php b/lib/util.php
index e03667b0794..ef77ba8a916 100755
--- a/lib/util.php
+++ b/lib/util.php
@@ -98,7 +98,7 @@ class OC_Util {
public static function getVersion() {
// hint: We only can count up. Reset minor/patchlevel when
// updating major/minor version number.
- return array(5, 80, 05);
+ return array(5, 80, 06);
}
/**
@@ -352,10 +352,10 @@ class OC_Util {
$encryptedFiles = true;
}
}
-
+
return $encryptedFiles;
}
-
+
/**
* Check for correct file permissions of data directory
* @return array arrays with error messages and hints
@@ -581,16 +581,16 @@ class OC_Util {
}
return $value;
}
-
+
/**
* @brief Public function to encode url parameters
*
* This function is used to encode path to file before output.
* Encoding is done according to RFC 3986 with one exception:
- * Character '/' is preserved as is.
+ * Character '/' is preserved as is.
*
* @param string $component part of URI to encode
- * @return string
+ * @return string
*/
public static function encodePath($component) {
$encoded = rawurlencode($component);
@@ -734,7 +734,7 @@ class OC_Util {
}
}
-
+
/**
* Check if the connection to the internet is disabled on purpose
*/
@@ -887,7 +887,7 @@ class OC_Util {
$theme = OC_Config::getValue("theme", '');
if($theme === '') {
-
+
if(is_dir(OC::$SERVERROOT . '/themes/default')) {
$theme = 'default';
}