Beispiel #1
0
 /**
  * Update attachment record
  *
  * @return  void
  */
 public function saveItem($manifest, $blockId, $pub, $actor = 0, $elementId = 0, $aid = 0)
 {
     $aid = $aid ? $aid : Request::getInt('aid', 0);
     // Load classes
     $row = new \Components\Publications\Tables\Author($this->_parent->_db);
     $objO = new \Components\Projects\Tables\Owner($this->_parent->_db);
     // We need attachment record
     if (!$aid || !$row->load($aid) || $row->publication_version_id != $pub->version_id) {
         $this->setError(Lang::txt('PLG_PROJECTS_PUBLICATIONS_CONTENT_ERROR_LOAD_AUTHOR'));
         return false;
     }
     // Instantiate a new registration object
     include_once PATH_CORE . DS . 'components' . DS . 'com_members' . DS . 'models' . DS . 'registration.php';
     $xregistration = new \Components\Members\Models\Registration();
     // Get current owners
     $owners = $objO->getIds($pub->_project->get('id'), 'all', 1);
     $email = Request::getVar('email', '', 'post');
     $firstName = Request::getVar('firstName', '', 'post');
     $lastName = Request::getVar('lastName', '', 'post');
     $org = Request::getVar('organization', '', 'post');
     $credit = Request::getVar('credit', '', 'post');
     $sendInvite = 0;
     $code = \Components\Projects\Helpers\Html::generateCode();
     $uid = Request::getInt('uid', 0, 'post');
     $regex = '/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-]+)+/';
     $email = preg_match($regex, $email) ? $email : '';
     if (!$firstName || !$lastName) {
         $this->setError(Lang::txt('PLG_PROJECTS_PUBLICATIONS_ERROR_MISSING_REQUIRED'));
         return false;
     }
     $row->organization = $org;
     $row->firstName = $firstName;
     $row->lastName = $lastName;
     $row->name = $row->firstName . ' ' . $row->lastName;
     $row->credit = $credit;
     $row->modified_by = $actor;
     $row->modified = Date::toSql();
     // Check that profile exists
     if ($uid) {
         $profile = User::getInstance($uid);
         $uid = $profile->get('id') ? $uid : 0;
     }
     // Tying author to a user account?
     if ($uid && !$row->user_id) {
         // Do we have an owner with this user id?
         $owner = $objO->getOwnerId($pub->_project->get('id'), $uid);
         if ($owner) {
             // Update owner assoc
             $row->project_owner_id = $owner;
         } else {
             // Update associated project owner account
             if ($objO->load($row->project_owner_id) && !$objO->userid) {
                 $objO->userid = $uid;
                 $objO->status = 1;
                 $objO->store();
             }
         }
     }
     $row->user_id = $uid;
     if ($row->store()) {
         $this->set('_message', Lang::txt('Author record saved'));
         // Reflect the update in curation record
         $this->_parent->set('_update', 1);
     } else {
         $this->setError(Lang::txt('PLG_PROJECTS_PUBLICATIONS_AUTHORS_ERROR_SAVING_AUTHOR_INFO'));
         return false;
     }
     // Update project owner (invited)
     if ($email && !$row->user_id && $objO->load($row->project_owner_id)) {
         $invitee = $objO->checkInvited($pub->_project->get('id'), $email);
         // Do we have a registered user with this email?
         $user = $xregistration->getEmailId($email);
         if ($invitee && $invitee != $row->project_owner_id) {
             // Stop, must have owner record
         } elseif (in_array($user, $owners)) {
             // Stop, already in team
         } elseif ($email != $objO->invited_email) {
             $objO->invited_email = $email;
             $objO->invited_name = $row->name;
             $objO->userid = $row->user_id;
             $objO->invited_code = $code;
             $objO->store();
             $sendInvite = 1;
         }
     }
     // (Re)send email invitation
     if ($sendInvite && $email) {
         // Get project model
         $project = new \Components\Projects\Models\Project($pub->_project->get('id'));
         // Plugin params
         $plugin_params = array(0, $email, $code, 2, $project, 'com_projects');
         // Send invite
         $output = Event::trigger('projects.sendInviteEmail', $plugin_params);
         $result = json_decode($output[0]);
     }
     return true;
 }
Beispiel #2
0
<?php 
foreach ($this->team as $owner) {
    // Get profile thumb image
    $profile = \Hubzero\User\Profile::getInstance($owner->userid);
    $actor = \Hubzero\User\Profile::getInstance($this->uid);
    $thumb = $profile ? $profile->getPicture() : $actor->getPicture(true);
    $timecheck = date('Y-m-d H:i:s', time() - 15 * 60);
    $lastvisit = $owner->lastvisit && $owner->lastvisit != '0000-00-00 00:00:00' ? \Components\Projects\Helpers\Html::timeAgo($owner->lastvisit) . ' ' . Lang::txt('PLG_PROJECTS_TEAM_AGO') : Lang::txt('PLG_PROJECTS_TEAM_NEVER');
    $lastvisit = $owner->userid == $this->uid || $owner->online && $owner->lastvisit > $timecheck ? '<span class="online">' . Lang::txt('PLG_PROJECTS_TEAM_ONLINE_NOW') . '</span>' : $lastvisit;
    // User deleted?
    // Edge case!
    if ($owner->userid && !$owner->username) {
        $objO = new \Components\Projects\Tables\Owner($this->database);
        $objO->load($owner->id);
        $objO->status = 2;
        $objO->store();
        continue;
    }
    $creator = $this->model->owner('id') == $owner->userid ? 1 : 0;
    // Determine css class for user
    switch ($owner->role) {
        case '1':
            $role = Lang::txt('PLG_PROJECTS_TEAM_LABEL_OWNER');
            break;
        case '2':
        default:
            $role = Lang::txt('PLG_PROJECTS_TEAM_LABEL_COLLABORATOR');
            break;
        case '5':
            $role = Lang::txt('PLG_PROJECTS_TEAM_LABEL_REVIEWER');
            break;