예제 #1
0
            break;
        default:
            $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;
    ?>
예제 #2
0
 /**
  * Download a picture
  *
  * @return  void
  */
 public function pictureTask()
 {
     //get vars
     $id = Request::getInt('id', 0);
     //check to make sure we have an id
     if (!$id || $id == 0) {
         return;
     }
     //Load member profile
     $member = Profile::getInstance($id);
     // check to make sure we have member profile
     if (!$member) {
         return;
     }
     $file = DS . trim($this->config->get('webpath', '/site/members'), DS);
     $file .= DS . Profile\Helper::niceidformat($member->get('uidNumber'));
     $file .= DS . Request::getVar('image', $member->get('picture'));
     // Ensure the file exist
     if (!file_exists(PATH_APP . DS . $file)) {
         App::abort(404, Lang::txt('COM_MEMBERS_FILE_NOT_FOUND') . ' ' . $file);
         return;
     }
     // Serve up the image
     $xserver = new \Hubzero\Content\Server();
     $xserver->filename(PATH_APP . DS . $file);
     $xserver->disposition('attachment');
     $xserver->acceptranges(false);
     // @TODO fix byte range support
     //serve up file
     if (!$xserver->serve()) {
         // Should only get here on error
         App::abort(404, Lang::txt('COM_MEMBERS_MEDIA_ERROR_SERVING_FILE'));
     } else {
         exit;
     }
     return;
 }
예제 #3
0
 /**
  * Download a file
  *
  * @return     void
  */
 public function downloadTask()
 {
     //get vars
     $id = Request::getInt('id', 0);
     //check to make sure we have an id
     if (!$id || $id == 0) {
         return;
     }
     //Load member profile
     $member = \Hubzero\User\Profile::getInstance($id);
     // check to make sure we have member profile
     if (!$member) {
         return;
     }
     //get the file name
     // make sure to leave out any query params (ex. ?v={timestamp})
     $uri = Request::getVar('SCRIPT_URL', '', 'server');
     if (strstr($uri, 'Image:')) {
         $file = str_replace('Image:', '', strstr($uri, 'Image:'));
     } elseif (strstr($uri, 'File:')) {
         $file = str_replace('File:', '', strstr($uri, 'File:'));
     }
     //decode file name
     $file = urldecode($file);
     // build base path
     $base_path = $this->filespace() . DS . \Hubzero\User\Profile\Helper::niceidformat($member->get('uidNumber'));
     //if we are on the blog
     if (Request::getVar('active', 'profile') == 'blog') {
         // @FIXME Check still needs to occur for non-public entries
         //authorize checks
         /*if ($this->_authorize() != 'admin')
         		{
         			if (User::get('id') != $member->get('uidNumber'))
         			{
         				App::abort(403, Lang::txt('You are not authorized to download the file: ') . ' ' . $file);
         				return;
         			}
         		}*/
         //get the params from the members blog plugin
         $blog_params = Plugin::params('members', 'blog');
         //build the base path to file based of upload path param
         $base_path = str_replace('{{uid}}', \Hubzero\User\Profile\Helper::niceidformat($member->get('uidNumber')), $blog_params->get('uploadpath'));
     }
     //build file path
     $file_path = $base_path . DS . $file;
     // Ensure the file exist
     if (!file_exists(PATH_APP . DS . $file_path)) {
         App::abort(404, Lang::txt('The requested file could not be found: ') . ' ' . $file);
         return;
     }
     // Serve up the image
     $xserver = new \Hubzero\Content\Server();
     $xserver->filename(PATH_APP . DS . $file_path);
     $xserver->disposition('attachment');
     $xserver->acceptranges(false);
     // @TODO fix byte range support
     //serve up file
     if (!$xserver->serve()) {
         // Should only get here on error
         App::abort(404, Lang::txt('An error occured while trying to output the file'));
     } else {
         exit;
     }
     return;
 }
예제 #4
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);
 }