Esempio n. 1
0
 /**
 Returns an users combo from a users record
 
 @param	users		<b>record</b>		the users record
 @return	<b>array</b> the combo box (form::combo -compatible format)
 */
 public static function getUsersCombo($users)
 {
     $users_combo = array();
     while ($users->fetch()) {
         $user_cn = dcUtils::getUserCN($users->user_id, $users->user_name, $users->user_firstname, $users->user_displayname);
         if ($user_cn != $users->user_id) {
             $user_cn .= ' (' . $users->user_id . ')';
         }
         $users_combo[$user_cn] = $users->user_id;
     }
     return $users_combo;
 }
Esempio n. 2
0
 #
 # Users on the blog (with permissions)
 $blog_users = $core->getBlogPermissions($blog_id, $core->auth->isSuperAdmin());
 $perm_types = $core->auth->getPermissionsTypes();
 echo '<div class="multi-part" id="users" title="' . __('Users') . '">' . '<h3>' . __('Users on this blog') . '</h3>';
 if (empty($blog_users)) {
     echo '<p>' . __('No users') . '</p>';
 } else {
     if ($core->auth->isSuperAdmin()) {
         $user_url_p = '<a href="user.php?id=%1$s">%1$s</a>';
     } else {
         $user_url_p = '%1$s';
     }
     foreach ($blog_users as $k => $v) {
         if (count($v['p']) > 0) {
             echo '<h4>' . sprintf($user_url_p, html::escapeHTML($k)) . ' (' . html::escapeHTML(dcUtils::getUserCN($k, $v['name'], $v['firstname'], $v['displayname'])) . ')';
             if (!$v['super'] && $core->auth->isSuperAdmin()) {
                 echo ' - <a href="permissions.php?blog_id[]=' . $blog_id . '&amp;user_id[]=' . $k . '">' . __('change permissions') . '</a>';
             }
             echo '</h4>';
             echo '<ul>';
             if ($v['super']) {
                 echo '<li>' . __('Super administrator') . '</li>';
             } else {
                 foreach ($v['p'] as $p => $V) {
                     echo '<li>' . __($perm_types[$p]) . '</li>';
                 }
             }
             echo '</ul>';
         }
     }
Esempio n. 3
0
 private function getAuthors($user, $pwd)
 {
     $this->setUser($user, $pwd);
     $this->setBlog();
     $rs = $this->core->getBlogPermissions($this->core->blog->id);
     $res = array();
     foreach ($rs as $k => $v) {
         $res[] = array('user_id' => $k, 'user_login' => $k, 'display_name' => dcUtils::getUserCN($k, $v['name'], $v['firstname'], $v['displayname']));
     }
     return $res;
 }
Esempio n. 4
0
 public static function getUserCN($rs)
 {
     $user = dcUtils::getUserCN($rs->user_id, $rs->user_name, $rs->user_firstname, $rs->user_displayname);
     if ($user === 'unknown') {
         $user = __('unknown');
     }
     return $user;
 }
 /**
 Returns author common name using user_id, user_name, user_firstname and
 user_displayname fields.
 
 @param	rs	Invisible parameter
 @return	<b>string</b>
 */
 public static function getAuthorCN(&$rs)
 {
     return dcUtils::getUserCN($rs->user_id, $rs->user_name, $rs->user_firstname, $rs->user_displayname);
 }
Esempio n. 6
0
 /**
  * Checks if user exists and can log in. <var>$pwd</var> argument is optionnal
  * while you may need to check user without password. This method will create
  * credentials and populate all needed object properties.
  *
  * @param string	$user_id		User ID
  * @param string	$pwd			User password
  * @param string	$user_key		User key check
  * @param boolean	$check_blog	checks if user is associated to a blog or not.
  * @return boolean
  */
 public function checkUser($user_id, $pwd = null, $user_key = null, $check_blog = true)
 {
     # Check user and password
     $strReq = 'SELECT user_id, user_super, user_pwd, user_change_pwd, ' . 'user_name, user_firstname, user_displayname, user_email, ' . 'user_url, user_default_blog, user_options, ' . 'user_lang, user_tz, user_post_status, user_creadt, user_upddt ' . 'FROM ' . $this->con->escapeSystem($this->user_table) . ' ' . "WHERE user_id = '" . $this->con->escape($user_id) . "' ";
     try {
         $rs = $this->con->select($strReq);
     } catch (Exception $e) {
         $err = $e->getMessage();
         return false;
     }
     if ($rs->isEmpty()) {
         sleep(rand(2, 5));
         return false;
     }
     $rs->extend('rsExtUser');
     if ($pwd != '') {
         if ($this->crypt($pwd) != $rs->user_pwd) {
             sleep(rand(2, 5));
             return false;
         }
     } elseif ($user_key != '') {
         if (http::browserUID(DC_MASTER_KEY . $rs->user_id . $rs->user_pwd) != $user_key) {
             return false;
         }
     }
     $this->user_id = $rs->user_id;
     $this->user_change_pwd = (bool) $rs->user_change_pwd;
     $this->user_admin = (bool) $rs->user_super;
     $this->user_info['user_pwd'] = $rs->user_pwd;
     $this->user_info['user_name'] = $rs->user_name;
     $this->user_info['user_firstname'] = $rs->user_firstname;
     $this->user_info['user_displayname'] = $rs->user_displayname;
     $this->user_info['user_email'] = $rs->user_email;
     $this->user_info['user_url'] = $rs->user_url;
     $this->user_info['user_default_blog'] = $rs->user_default_blog;
     $this->user_info['user_lang'] = $rs->user_lang;
     $this->user_info['user_tz'] = $rs->user_tz;
     $this->user_info['user_post_status'] = $rs->user_post_status;
     $this->user_info['user_creadt'] = $rs->user_creadt;
     $this->user_info['user_upddt'] = $rs->user_upddt;
     $this->user_info['user_cn'] = dcUtils::getUserCN($rs->user_id, $rs->user_name, $rs->user_firstname, $rs->user_displayname);
     $this->user_options = array_merge($this->core->userDefaults(), $rs->options());
     $this->user_prefs = new dcPrefs($this->core, $this->user_id);
     # Get permissions on blogs
     if ($check_blog && $this->findUserBlog() === false) {
         return false;
     }
     return true;
 }
Esempio n. 7
0
} catch (Exception $e) {
    $core->error->add($e->getMessage());
}
# Getting langs
try {
    $langs = $core->blog->getLangs();
} catch (Exception $e) {
    $core->error->add($e->getMessage());
}
# Creating filter combo boxes
if (!$core->error->flag()) {
    # Filter form we'll put in html_block
    $users_combo = $categories_combo = array();
    $users_combo['-'] = $categories_combo['-'] = '';
    while ($users->fetch()) {
        $user_cn = dcUtils::getUserCN($users->user_id, $users->user_name, $users->user_firstname, $users->user_displayname);
        if ($user_cn != $users->user_id) {
            $user_cn .= ' (' . $users->user_id . ')';
        }
        $users_combo[$user_cn] = $users->user_id;
    }
    while ($categories->fetch()) {
        $categories_combo[str_repeat('&nbsp;&nbsp;', $categories->level - 1) . '&bull; ' . html::escapeHTML($categories->cat_title) . ' (' . $categories->nb_post . ')'] = $categories->cat_id;
    }
    $status_combo = array('-' => '');
    foreach ($core->blog->getAllPostStatus() as $k => $v) {
        $status_combo[$v] = (string) $k;
    }
    $selected_combo = array('-' => '', __('selected') => '1', __('not selected') => '0');
    # Months array
    $dt_m_combo['-'] = '';
Esempio n. 8
0
 } else {
     if ($core->auth->isSuperAdmin()) {
         $user_url_p = '<a href="' . $core->adminurl->get("admin.user", array('id' => '%1$s'), '&amp;', true) . '">%1$s</a>';
     } else {
         $user_url_p = '%1$s';
     }
     # Sort users list on user_id key
     dcUtils::lexicalKeySort($blog_users);
     $post_type = $core->getPostTypes();
     $current_blog_id = $core->blog->id;
     if ($blog_id != $core->blog->id) {
         $core->setBlog($blog_id);
     }
     foreach ($blog_users as $k => $v) {
         if (count($v['p']) > 0) {
             echo '<div class="user-perm">' . '<h4>' . sprintf($user_url_p, html::escapeHTML($k)) . ' (' . html::escapeHTML(dcUtils::getUserCN($k, $v['name'], $v['firstname'], $v['displayname'])) . ')</h4>';
             if ($core->auth->isSuperAdmin()) {
                 echo '<p>' . __('Email:') . ' ' . ($v['email'] != '' ? '<a href="mailto:' . $v['email'] . '">' . $v['email'] . '</a>' : __('(none)')) . '</p>';
             }
             echo '<h5>' . __('Publications on this blog:') . '</h5>' . '<ul>';
             foreach ($post_type as $type => $pt_info) {
                 $params = array('post_type' => $type, 'user_id' => $k);
                 echo '<li>' . sprintf(__('%1$s: %2$s'), __($pt_info['label']), $core->blog->getPosts($params, true)->f(0)) . '</li>';
             }
             echo '</ul>';
             echo '<h5>' . __('Permissions:') . '</h5>' . '<ul>';
             if ($v['super']) {
                 echo '<li class="user_super">' . __('Super administrator') . '<br />' . '<span class="form-note">' . __('All rights on all blogs.') . '</span></li>';
             } else {
                 foreach ($v['p'] as $p => $V) {
                     if (isset($perm_types[$p])) {