diff --git a/program/lib/Roundcube/rcube_imap_generic.php b/program/lib/Roundcube/rcube_imap_generic.php index 3dac8a55c..7d7cc210c 100644 --- a/program/lib/Roundcube/rcube_imap_generic.php +++ b/program/lib/Roundcube/rcube_imap_generic.php @@ -2250,7 +2250,7 @@ class rcube_imap_generic } $result = $this->execute('UID STORE', array( - $this->compressMessageSet($messages), $mod . 'FLAGS.SILENT', "($flag)"), + $this->compressMessageSet($messages), $mod . 'FLAGS', "($flag)"), self::COMMAND_NORESPONSE); return $result == self::ERROR_OK; diff --git a/program/lib/Roundcube/rcube_user.php b/program/lib/Roundcube/rcube_user.php index ad442436c..77556f9e0 100644 --- a/program/lib/Roundcube/rcube_user.php +++ b/program/lib/Roundcube/rcube_user.php @@ -91,7 +91,8 @@ class rcube_user /** * Build a user name string (as e-mail address) * - * @param string $part Username part (empty or 'local' or 'domain', 'mail') + * @param string $part Username part (empty or 'local' or 'domain', 'mail') + * * @return string Full user name or its part */ function get_username($part = null) @@ -117,13 +118,12 @@ class rcube_user return $domain; } - if (!empty($domain)) + if (!empty($domain)) { return $local . '@' . $domain; - else - return $local; - } + } - return false; + return $local; + } } /** @@ -175,14 +175,18 @@ class rcube_user */ function save_prefs($a_user_prefs, $no_session = false) { - if (!$this->ID) + if (!$this->ID) { return false; + } $plugin = $this->rc->plugins->exec_hook('preferences_update', array( - 'userid' => $this->ID, 'prefs' => $a_user_prefs, 'old' => (array)$this->get_prefs())); + 'userid' => $this->ID, + 'prefs' => $a_user_prefs, + 'old' => (array)$this->get_prefs() + )); if (!empty($plugin['abort'])) { - return; + return false; } $a_user_prefs = $plugin['prefs']; @@ -262,7 +266,7 @@ class rcube_user /** * Return a list of all user emails (from identities) * - * @param bool Return only default identity + * @param bool $default Return only default identity * * @return array List of emails (identity_id, name, email) */ @@ -289,7 +293,8 @@ class rcube_user /** * Get default identity of this user * - * @param int $id Identity ID. If empty, the default identity is returned + * @param int $id Identity ID. If empty, the default identity is returned + * * @return array Hash array with all cols of the identity record */ function get_identity($id = null) @@ -342,14 +347,16 @@ class rcube_user /** * Update a specific identity record * - * @param int $iid Identity ID - * @param array $data Hash array with col->value pairs to save + * @param int $iid Identity ID + * @param array $data Hash array with col->value pairs to save + * * @return boolean True if saved successfully, false if nothing changed */ function update_identity($iid, $data) { - if (!$this->ID) + if (!$this->ID) { return false; + } $query_cols = $query_params = array(); @@ -373,19 +380,21 @@ class rcube_user $this->identities = array(); $this->emails = null; - return $this->db->affected_rows(); + return $this->db->affected_rows() > 0; } /** * Create a new identity record linked with this user * * @param array $data Hash array with col->value pairs to save - * @return int The inserted identity ID or false on error + * + * @return int The inserted identity ID or false on error */ function insert_identity($data) { - if (!$this->ID) + if (!$this->ID) { return false; + } unset($data['user_id']); @@ -408,19 +417,21 @@ class rcube_user $this->identities = array(); $this->emails = null; - return $this->db->insert_id('identities'); + return $this->db->insert_id('identities') ?: false; } /** * Mark the given identity as deleted * - * @param int $iid Identity ID + * @param int $iid Identity ID + * * @return boolean True if deleted successfully, false if nothing changed */ function delete_identity($iid) { - if (!$this->ID) + if (!$this->ID) { return false; + } $sql_result = $this->db->query( "SELECT count(*) AS ident_count FROM ".$this->db->table_name('identities', true). @@ -430,8 +441,9 @@ class rcube_user $sql_arr = $this->db->fetch_assoc($sql_result); // we'll not delete last identity - if ($sql_arr['ident_count'] <= 1) - return -1; + if ($sql_arr['ident_count'] <= 1) { + return false; + } $this->db->query( "UPDATE ".$this->db->table_name('identities', true). @@ -445,7 +457,7 @@ class rcube_user $this->identities = array(); $this->emails = null; - return $this->db->affected_rows(); + return $this->db->affected_rows() > 0; } /** @@ -545,6 +557,7 @@ class rcube_user * * @param string $user IMAP user name * @param string $host IMAP host name + * * @return rcube_user New user instance */ static function query($user, $host) @@ -572,8 +585,6 @@ class rcube_user if ($sql_arr) { return new rcube_user($sql_arr['user_id'], $sql_arr); } - - return false; } /** @@ -581,6 +592,7 @@ class rcube_user * * @param string $user IMAP user name * @param string $host IMAP host + * * @return rcube_user New user instance */ static function create($user, $host) @@ -606,7 +618,7 @@ class rcube_user // plugin aborted this operation if ($data['abort']) { - return false; + return; } $dbh->query( @@ -686,20 +698,21 @@ class rcube_user 'message' => "Failed to create new user"), true, false); } - return $user_id ? $user_instance : false; + return $user_id ? $user_instance : null; } /** * Resolve username using a virtuser plugins * * @param string $email E-mail address to resolve + * * @return string Resolved IMAP username */ static function email2user($email) { $rcube = rcube::get_instance(); $plugin = $rcube->plugins->exec_hook('email2user', - array('email' => $email, 'user' => NULL)); + array('email' => $email, 'user' => null)); return $plugin['user']; } @@ -707,25 +720,26 @@ class rcube_user /** * Resolve e-mail address from virtuser plugins * - * @param string $user User name - * @param boolean $first If true returns first found entry + * @param string $user User name + * @param boolean $first If true returns first found entry * @param boolean $extended If true returns email as array (email and name for identity) + * * @return mixed Resolved e-mail address string or array of strings */ static function user2email($user, $first=true, $extended=false) { $rcube = rcube::get_instance(); $plugin = $rcube->plugins->exec_hook('user2email', - array('email' => NULL, 'user' => $user, + array('email' => null, 'user' => $user, 'first' => $first, 'extended' => $extended)); - return empty($plugin['email']) ? NULL : $plugin['email']; + return empty($plugin['email']) ? null : $plugin['email']; } /** * Return a list of saved searches linked with this user * - * @param int $type Search type + * @param int $type Search type * * @return array List of saved searches indexed by search ID */ @@ -757,7 +771,7 @@ class rcube_user /** * Return saved search data. * - * @param int $id Row identifier + * @param int $id Row identifier * * @return array Data */ @@ -784,21 +798,20 @@ class rcube_user 'data' => unserialize($sql_arr['data']), ); } - - return null; } /** * Deletes given saved search record * - * @param int $sid Search ID + * @param int $sid Search ID * * @return boolean True if deleted successfully, false if nothing changed */ function delete_search($sid) { - if (!$this->ID) + if (!$this->ID) { return false; + } $this->db->query( "DELETE FROM ".$this->db->table_name('searches', true) @@ -806,7 +819,7 @@ class rcube_user ." AND `search_id` = ?", (int) $this->ID, $sid); - return $this->db->affected_rows(); + return $this->db->affected_rows() > 0; } /** @@ -814,12 +827,13 @@ class rcube_user * * @param array $data Hash array with col->value pairs to save * - * @return int The inserted search ID or false on error + * @return int The inserted search ID or false on error */ function insert_search($data) { - if (!$this->ID) + if (!$this->ID) { return false; + } $insert_cols[] = 'user_id'; $insert_values[] = (int) $this->ID; @@ -837,6 +851,6 @@ class rcube_user call_user_func_array(array($this->db, 'query'), array_merge(array($sql), $insert_values)); - return $this->db->insert_id('searches'); + return $this->db->insert_id('searches') ?: false; } }