Esempio n. 1
0
 /**
  * Gets the full name of a user from their ID #
  *
  * @return     string
  */
 public function authorTask()
 {
     $this->view->id = Request::getVar('u', '');
     $this->view->role = Request::getVar('role', '');
     $rid = Request::getInt('rid', 0);
     // Get the member's info
     $profile = new \Hubzero\User\Profile();
     $profile->load($this->view->id);
     if (!is_object($profile) || !$profile->get('uidNumber')) {
         $this->database->setQuery("SELECT id FROM `#__users` WHERE `name`=" . $this->database->Quote($this->view->id));
         if ($id = $this->database->loadResult()) {
             $profile->load($id);
         }
     }
     if (is_object($profile) && $profile->get('uidNumber')) {
         if (!$profile->get('name')) {
             $this->view->name = $profile->get('givenName') . ' ';
             $this->view->name .= $profile->get('middleName') ? $profile->get('middleName') . ' ' : '';
             $this->view->name .= $profile->get('surname');
         } else {
             $this->view->name = $profile->get('name');
         }
         $this->view->org = $profile->get('organization');
         $this->view->id = $profile->get('uidNumber');
     } else {
         $this->view->name = null;
         include_once dirname(dirname(__DIR__)) . DS . 'tables' . DS . 'contributor.php';
         $rcc = new Contributor($this->database);
         if (is_numeric($this->view->id)) {
             $this->database->setQuery("SELECT name, organization FROM `#__author_assoc` WHERE authorid=" . $this->database->Quote($this->view->id) . " LIMIT 1");
             $author = $this->database->loadObject();
             if (is_object($author) && $author->name) {
                 $this->view->name = $author->name;
                 $this->view->org = $author->organization;
             }
         }
         if (!$this->view->name) {
             $this->view->org = '';
             $this->view->name = str_replace('_', ' ', $this->view->id);
             $this->view->id = $rcc->getUserId($this->view->name);
         }
     }
     $row = new Resource($this->database);
     $row->load($rid);
     $rt = new Type($this->database);
     $this->view->roles = $rt->getRolesForType($row->type);
     $this->view->display();
 }