Exemplo n.º 1
0
 /**
  * Return results for autocompleter
  *
  * @return     string JSON
  */
 public function autocompleteTask()
 {
     if (User::isGuest()) {
         return;
     }
     $restrict = '';
     $filters = array();
     $filters['limit'] = 20;
     $filters['start'] = 0;
     $filters['search'] = strtolower(trim(Request::getString('value', '')));
     // Fetch results
     $query = "SELECT xp.uidNumber, xp.name, xp.username, xp.organization, xp.picture, xp.public\n\t\t\t\tFROM `#__xprofiles` AS xp\n\t\t\t\tINNER JOIN `#__users` u ON u.id = xp.uidNumber AND u.block = 0\n\t\t\t\tWHERE LOWER(xp.name) LIKE " . $this->database->quote('%' . $filters['search'] . '%') . " AND xp.emailConfirmed>0 {$restrict}\n\t\t\t\tORDER BY xp.name ASC";
     $this->database->setQuery($query);
     $rows = $this->database->loadObjectList();
     $base = str_replace('/administrator', '', rtrim(Request::base(true), '/'));
     // Output search results in JSON format
     $json = array();
     if (count($rows) > 0) {
         $default = DS . trim($this->config->get('defaultpic', '/core/components/com_members/site/assets/img/profile.gif'), DS);
         $default = Profile\Helper::thumbit($default);
         foreach ($rows as $row) {
             $picture = $default;
             $name = str_replace("\n", '', stripslashes(trim($row->name)));
             $name = str_replace("\r", '', $name);
             $name = str_replace('\\', '', $name);
             if ($row->public && $row->picture) {
                 $thumb = $base . DS . trim($this->config->get('webpath', '/site/members'), DS);
                 $thumb .= DS . Profile\Helper::niceidformat($row->uidNumber);
                 $thumb .= DS . ltrim($row->picture, DS);
                 $thumb = Profile\Helper::thumbit($thumb);
                 if (file_exists(PATH_APP . $thumb)) {
                     $picture = $thumb;
                 }
             }
             $obj = array();
             $obj['id'] = $row->uidNumber;
             $obj['name'] = $name;
             $obj['org'] = $row->public ? $row->organization : '';
             $obj['picture'] = $picture;
             $json[] = $obj;
         }
     }
     echo json_encode($json);
 }
Exemplo n.º 2
0
            $task = 'confirm';
            $img = 'publish_x.png';
            $alt = Lang::txt('JNO');
            $state = 'unpublish';
            break;
    }
    if (!$row->lastvisitDate || $row->lastvisitDate == "0000-00-00 00:00:00") {
        $lvisit = '<span class="never" style="color:#bbb;">' . Lang::txt('COM_MEMBERS_NEVER') . '</span>';
    } else {
        $lvisit = '<time datetime="' . $row->lastvisitDate . '">' . Date::of($row->lastvisitDate)->toLocal('Y-m-d') . '</time>';
    }
    if ($row->picture) {
        $thumb = substr(PATH_APP, strlen(PATH_ROOT)) . DS . trim($this->config->get('webpath'), DS);
        $thumb .= DS . \Hubzero\User\Profile\Helper::niceidformat($row->uidNumber);
        $thumb .= DS . ltrim($row->picture, DS);
        $thumb = \Hubzero\User\Profile\Helper::thumbit($thumb);
        if (file_exists(PATH_ROOT . $thumb)) {
            $picture = $thumb;
        }
    }
    ?>
			<tr class="<?php 
    echo "row{$k}";
    ?>
">
				<td>
					<input type="checkbox" name="id[]" id="cb<?php 
    echo $i;
    ?>
" value="<?php 
    echo $row->uidNumber;
Exemplo n.º 3
0
 /**
  * Return results for autocompleter
  *
  * @return     string JSON
  */
 public function autocompleteTask()
 {
     if (User::isGuest()) {
         return;
     }
     $restrict = '';
     $referrer = Request::getVar('HTTP_REFERER', NULL, 'server');
     if ($referrer && preg_match('/members\\/\\d+\\/messages/i', $referrer)) {
         if (!User::authorise('core.admin', $this->_option) && !User::authorise('core.manage', $this->_option)) {
             switch ($this->config->get('user_messaging')) {
                 case 2:
                     $restrict = " AND xp.public=1";
                     break;
                 case 1:
                 default:
                     $profile = \Hubzero\User\Profile::getInstance(User::get('id'));
                     $xgroups = $profile->getGroups('all');
                     $usersgroups = array();
                     if (!empty($xgroups)) {
                         foreach ($xgroups as $group) {
                             if ($group->regconfirmed) {
                                 $usersgroups[] = $group->gidNumber;
                             }
                         }
                     }
                     $members = null;
                     if (!empty($usersgroups)) {
                         $query = "SELECT DISTINCT uidNumber\n\t\t\t\t\t\t\t\t\tFROM `#__xgroups_members`\n\t\t\t\t\t\t\t\t\tWHERE gidNumber IN (" . implode(',', $usersgroups) . ")";
                         $this->database->setQuery($query);
                         $members = $this->database->loadColumn();
                     }
                     if (!$members || empty($members)) {
                         $members = array(User::get('id'));
                     }
                     $restrict = " AND xp.uidNumber IN (" . implode(',', $members) . ")";
                     break;
             }
         }
     }
     $filters = array();
     $filters['limit'] = 20;
     $filters['start'] = 0;
     $filters['search'] = strtolower(trim(Request::getString('value', '')));
     $originalQuery = $filters['search'];
     // match against orcid id
     if (preg_match('/\\d{4}-\\d{4}-\\d{4}-\\d{4}/', $filters['search'])) {
         $query = "SELECT xp.uidNumber, xp.name, xp.username, xp.organization, xp.picture, xp.public\n\t\t\t\t\tFROM #__xprofiles AS xp\n\t\t\t\t\tINNER JOIN #__users u ON u.id = xp.uidNumber AND u.block = 0\n\t\t\t\t\tWHERE orcid= " . $this->database->quote($filters['search']) . " AND xp.emailConfirmed>0 {$restrict}\n\t\t\t\t\tORDER BY xp.name ASC\n\t\t\t\t\tLIMIT " . $filters['start'] . "," . $filters['limit'];
     } else {
         // add trailing wildcard
         $filters['search'] = $filters['search'] . '*';
         // match member names on all three name parts
         $match = "MATCH(xp.givenName,xp.middleName,xp.surname) AGAINST(" . $this->database->quote($filters['search']) . " IN BOOLEAN MODE)";
         $query = "SELECT xp.uidNumber, xp.name, xp.username, xp.organization, xp.picture, xp.public, {$match} as rel\n\t\t\t\t\tFROM #__xprofiles AS xp\n\t\t\t\t\tINNER JOIN #__users u ON u.id = xp.uidNumber AND u.block = 0\n\t\t\t\t\tWHERE {$match} AND xp.emailConfirmed>0 {$restrict}\n\t\t\t\t\tORDER BY rel DESC, xp.name ASC\n\t\t\t\t\tLIMIT " . $filters['start'] . "," . $filters['limit'];
     }
     $this->database->setQuery($query);
     $rows = $this->database->loadObjectList();
     // Output search results in JSON format
     $json = array();
     if (count($rows) > 0) {
         $default = DS . trim($this->config->get('defaultpic', '/core/components/com_members/site/assets/img/profile.gif'), DS);
         if ($default == '/components/com_members/assets/img/profile.gif') {
             $default = '/core/components/com_members/site/assets/img/profile.gif';
         }
         $default = \Hubzero\User\Profile\Helper::thumbit($default);
         foreach ($rows as $row) {
             $picture = $default;
             $name = str_replace("\n", '', stripslashes(trim($row->name)));
             $name = str_replace("\r", '', $name);
             $name = str_replace('\\', '', $name);
             if ($row->public && $row->picture) {
                 $thumb = DS . trim($this->config->get('webpath', '/site/members'), DS);
                 $thumb .= DS . \Hubzero\User\Profile\Helper::niceidformat($row->uidNumber);
                 $thumb .= DS . ltrim($row->picture, DS);
                 $thumb = \Hubzero\User\Profile\Helper::thumbit($thumb);
                 if (file_exists(PATH_APP . $thumb)) {
                     $picture = substr(PATH_APP, strlen(PATH_ROOT)) . $thumb;
                 }
             }
             $obj = array();
             $obj['id'] = $row->uidNumber;
             $obj['name'] = $name;
             $obj['org'] = $row->public ? $row->organization : '';
             $obj['picture'] = $picture;
             $json[] = $obj;
         }
     }
     // formats names in the autocompleter
     if (!\Hubzero\Utility\Validate::email($originalQuery) && str_word_count($originalQuery) >= 2) {
         $originalQuery = ucwords($originalQuery);
     }
     //original query
     $obj = array();
     $obj['name'] = $originalQuery;
     $obj['id'] = $originalQuery;
     $obj['org'] = '';
     $obj['picture'] = '';
     $obj['orig'] = true;
     //add back original query
     array_unshift($json, $obj);
     echo json_encode($json);
 }