コード例 #1
0
 /**
  * Constructor
  *
  * @param   integer  $referenceid  Scope ID (group, course, etc.)
  * @return  void
  */
 public function __construct($referenceid = 0)
 {
     $this->set('referenceid', $referenceid)->set('category', 'publication')->set('option', $this->_segments['option']);
     $database = \App::get('db');
     $objP = new \Components\Publications\Tables\Publication($database);
     $this->_item = $objP->getPublication($referenceid, 'default');
     //$this->_segments['id']     = $this->_item->id;
     $this->_segments['active'] = 'wishlist';
 }
コード例 #2
0
ファイル: helper.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Display module content
  *
  * @return  void
  */
 public function display()
 {
     $database = \App::get('db');
     $config = Component::params('com_publications');
     // Get some classes we need
     require_once Component::path('com_publications') . DS . 'tables' . DS . 'publication.php';
     require_once Component::path('com_publications') . DS . 'tables' . DS . 'master.type.php';
     $this->moduleclass = $this->params->get('moduleclass');
     // Build query
     $filters = array('limit' => intval($this->params->get('limit', 10)), 'start' => 0, 'sortby' => 'title', 'sortdir' => 'ASC', 'ignore_access' => 1, 'curator' => 'owner', 'dev' => 1, 'status' => array(5, 7));
     // Instantiate
     $objP = new \Components\Publications\Tables\Publication($database);
     // Assigned curation
     $this->rows = $objP->getRecords($filters);
     require $this->getLayoutPath();
 }
コード例 #3
0
ファイル: citations.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * Determine if user is part of publication project and is allowed to edit citation
  *
  * @param   array  $assocs
  * @return  void
  */
 public function isPubAuthor($assocs)
 {
     if (!$assocs) {
         return false;
     }
     if (!is_file(PATH_ROOT . DS . 'components' . DS . 'com_publications' . DS . 'tables' . DS . 'publication.php')) {
         return false;
     }
     require_once PATH_ROOT . DS . 'components' . DS . 'com_publications' . DS . 'tables' . DS . 'publication.php';
     require_once PATH_ROOT . DS . 'components' . DS . 'com_projects' . DS . 'tables' . DS . 'owner.php';
     // Get connections to publications
     foreach ($assocs as $entry) {
         if ($entry->tbl == 'publication') {
             $pubID = $entry->oid;
             $objP = new \Components\Publications\Tables\Publication($this->database);
             if ($objP->load($pubID)) {
                 $objO = new \ProjectOwner($this->database);
                 if ($objO->isOwner(User::get('id'), $objP->project_id)) {
                     return true;
                 }
             }
         }
     }
     return false;
 }
コード例 #4
0
ファイル: files.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * Show disk usage
  *
  * @param   object   $model     Project model
  * @param   string   $repoName
  * @param   integer  $by
  * @return  string
  */
 public function diskspace($model, $repoName = 'local', $by = '')
 {
     // Output HTML
     $view = new \Hubzero\Plugin\View(array('folder' => 'projects', 'element' => 'files', 'name' => 'diskspace'));
     if (!isset($this->repo)) {
         $this->repo = new \Components\Projects\Models\Repo($model, $repoName);
     }
     $url = Route::url('index.php?option=' . $this->_option . '&alias=' . $model->get('alias') . '&active=files&action=diskspace');
     // Report usage with all history?
     if ($this->params->get('disk_usage') == true || $by == 'admin') {
         $view->dirsize = $this->repo->call('getDiskUsage', $params = array('working' => true, 'history' => true));
         $view->totalspace = $this->repo->call('getDiskUsage', $params = array('working' => false, 'history' => false));
     } else {
         $view->totalspace = $this->repo->call('getDiskUsage', $params = array('working' => false, 'history' => true));
         $view->dirsize = $view->totalspace;
     }
     // Get publication usage
     if (Plugin::isEnabled('projects', 'publications') && $by == 'admin') {
         require_once Component::path('com_publications') . DS . 'helpers' . DS . 'html.php';
         $filters = array();
         $filters['project'] = $model->get('id');
         $filters['ignore_access'] = 1;
         $filters['dev'] = 1;
         $database = \App::get('db');
         $objP = new \Components\Publications\Tables\Publication($database);
         $pubs = $objP->getRecords($filters);
         $view->pubDiskUsage = \Components\Publications\Helpers\Html::getDiskUsage($pubs);
         $view->pubQuota = $model->params->get('pubQuota') ? $model->params->get('pubQuota') : \Components\Projects\Helpers\Html::convertSize(floatval($model->config()->get('pubQuota', '1')), 'GB', 'b');
     }
     $view->total = $this->repo->count();
     $view->quota = $model->params->get('quota', \Components\Projects\Helpers\Html::convertSize(floatval($model->config()->get('defaultQuota', '1')), 'GB', 'b'));
     $view->by = $by;
     $view->model = $model;
     $view->option = $this->_option;
     $view->config = $model->config();
     $view->title = isset($this->_area['title']) ? $this->_area['title'] : '';
     $view->params = $this->params;
     return $view->loadTemplate();
 }
コード例 #5
0
ファイル: impact.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Return either a count or an array of the member's contributions
  *
  * @param      object  $member     Current member
  * @param      string  $option     Component name
  * @param      string  $authorized Authorization level
  * @param      integer $limit      Number of record to return
  * @param      integer $limitstart Record return start
  * @param      string  $sort       Field to sort records on
  * @param      array   $areas      Areas to return data for
  * @return     array
  */
 public function onMembersContributions($member, $option, $limit = 0, $limitstart = 0, $sort, $areas = null)
 {
     if (is_array($areas) && $limit && count($this->onMembersContributionsAreas()) > 0) {
         if (!isset($areas[$this->_name]) && !in_array($this->_name, $areas) && !array_intersect($areas, array_keys($this->onMembersContributionsAreas()))) {
             return array();
         }
     }
     // Do we have a member ID?
     if ($member instanceof \Hubzero\User\Profile) {
         if (!$member->get('uidNumber')) {
             return array();
         } else {
             $uidNumber = $member->get('uidNumber');
             $username = $member->get('username');
         }
     } else {
         if (!$member->uidNumber) {
             return array();
         } else {
             $uidNumber = $member->uidNumber;
             $username = $member->username;
         }
     }
     // Instantiate some needed objects
     $database = App::get('db');
     $objP = new \Components\Publications\Tables\Publication($database);
     // Build query
     $filters = array('sortby' => $sort, 'limit' => $limit, 'start' => $limitstart, 'author' => $uidNumber);
     if (!$limit) {
         $results = $objP->getCount($filters);
         return $results;
     } else {
         $rows = $objP->getRecords($filters);
         if ($rows) {
             foreach ($rows as $key => $row) {
                 if ($row->alias) {
                     $sef = Route::url('index.php?option=com_publications&alias=' . $row->alias . '&v=' . $row->version_number);
                 } else {
                     $sef = Route::url('index.php?option=com_publications&id=' . $row->id . '&v=' . $row->version_number);
                 }
                 $rows[$key]->href = $sef;
                 $rows[$key]->text = $rows[$key]->abstract;
                 $rows[$key]->section = 'impact';
                 $rows[$key]->author = $uidNumber == User::get('id') ? true : false;
             }
         }
         return $rows;
     }
 }
コード例 #6
0
 /**
  * Get disk space
  *
  * @param      object  	$model
  *
  * @return     string
  */
 public function pubDiskSpace($model)
 {
     // Output HTML
     $view = new \Hubzero\Plugin\View(array('folder' => 'projects', 'element' => 'publications', 'name' => 'diskspace'));
     // Include styling and js
     \Hubzero\Document\Assets::addPluginStylesheet('projects', 'files', 'diskspace');
     \Hubzero\Document\Assets::addPluginScript('projects', 'files', 'diskspace');
     $database = App::get('db');
     // Build query
     $filters = array();
     $filters['limit'] = Request::getInt('limit', 25);
     $filters['start'] = Request::getInt('limitstart', 0);
     $filters['sortby'] = Request::getVar('t_sortby', 'title');
     $filters['sortdir'] = Request::getVar('t_sortdir', 'ASC');
     $filters['project'] = $model->get('id');
     $filters['ignore_access'] = 1;
     $filters['dev'] = 1;
     // get dev versions
     // Instantiate project publication
     $objP = new \Components\Publications\Tables\Publication($database);
     // Get all publications
     $view->rows = $objP->getRecords($filters);
     // Get used space
     $view->dirsize = \Components\Publications\Helpers\Html::getDiskUsage($view->rows);
     $view->params = $model->params;
     $view->quota = $view->params->get('pubQuota') ? $view->params->get('pubQuota') : \Components\Projects\Helpers\Html::convertSize(floatval($model->config()->get('pubQuota', '1')), 'GB', 'b');
     // Get total count
     $view->total = $objP->getCount($filters);
     $view->project = $model;
     $view->option = $this->_option;
     $view->title = isset($this->_area['title']) ? $this->_area['title'] : '';
     return $view->loadTemplate();
 }
コード例 #7
0
 /**
  * Save block content
  *
  * @return  string  HTML
  */
 public function save($manifest = NULL, $blockId = 0, $pub = NULL, $actor = 0, $elementId = 0)
 {
     // Set block manifest
     if ($this->_manifest === NULL) {
         $this->_manifest = $manifest ? $manifest : self::getManifest();
     }
     // Make sure changes are allowed
     if ($this->_parent->checkFreeze($this->_manifest->params, $pub)) {
         return false;
     }
     // Load publication version
     $objP = new \Components\Publications\Tables\Publication($this->_parent->_db);
     if (!$objP->load($pub->id)) {
         $this->setError(Lang::txt('PLG_PROJECTS_PUBLICATIONS_PUBLICATION_NOT_FOUND'));
         return false;
     }
     if (!isset($pub->_citations)) {
         // Get citations for this publication
         $c = new \Components\Citations\Tables\Citation($this->_parent->_db);
         $pub->_citations = $c->getCitations('publication', $pub->id);
     }
     // Incoming
     $url = Request::getVar('citation-doi', '');
     if (!$url) {
         return true;
     }
     $parts = explode("doi:", $url);
     $doi = count($parts) > 1 ? $parts[1] : $url;
     $citationFormat = $pub->config('citation_format', 'apa');
     // Plugin params
     $plugin_params = array($pub->id, $doi, $citationFormat, $actor, true);
     // Attach citation
     $output = Event::trigger('projects.attachCitation', $plugin_params);
     if (isset($output[0])) {
         if ($output[0]['success']) {
             $this->set('_message', Lang::txt('PLG_PROJECTS_PUBLICATIONS_CITATION_SAVED'));
             // Reflect the update in curation record
             $this->_parent->set('_update', 1);
         } else {
             $this->setError($output[0]['error']);
             return false;
         }
     } else {
         $this->setError(Lang::txt('PLG_PROJECTS_PUBLICATIONS_CITATION_ERROR_SAVING'));
         return false;
     }
     return true;
 }
コード例 #8
0
ファイル: stats.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Collect overall projects stats
  *
  * @return  array
  */
 public function getStats($model, $cron = false, $publishing = false, $period = 'alltime', $limit = 3)
 {
     // Incoming
     $period = Request::getVar('period', $period);
     $limit = Request::getInt('limit', $limit);
     if ($cron == true) {
         $publicOnly = false;
         $saveLog = true;
     } else {
         $publicOnly = $model->reviewerAccess('admin') ? false : true;
         $saveLog = false;
     }
     // Collectors
     $stats = array();
     $updated = NULL;
     $lastLog = NULL;
     $pastMonth = Date::of(time() - 32 * 24 * 60 * 60)->toSql('Y-m-d');
     $thisYearNum = Date::format('y');
     $thisMonthNum = Date::format('m');
     $thisWeekNum = Date::format('W');
     // Pull recent stats
     if ($this->loadLog($thisYearNum, $thisMonthNum, $thisWeekNum)) {
         $lastLog = json_decode($this->stats, true);
         $updated = $this->processed;
     } else {
         // Save stats
         $saveLog = true;
     }
     // Get project table class
     $tbl = $model->table();
     // Get inlcude /exclude lists
     $exclude = $tbl->getProjectsByTag('test', true, 'id');
     $include = $tbl->getProjectsByTag('test', false, 'id');
     $validProjects = $tbl->getProjectsByTag('test', false, 'alias');
     $validCount = count($validProjects) > 0 ? count($validProjects) : 1;
     // Collect overview stats
     $stats['general'] = array('total' => $tbl->getCount(array('exclude' => $exclude, 'all' => 1), true), 'setup' => $tbl->getCount(array('exclude' => $exclude, 'setup' => 1), true), 'active' => $tbl->getCount(array('exclude' => $exclude, 'active' => 1), true), 'public' => $tbl->getCount(array('exclude' => $exclude, 'private' => '0'), true), 'sponsored' => $tbl->getCount(array('exclude' => $exclude, 'reviewer' => 'sponsored'), true), 'sensitive' => $tbl->getCount(array('exclude' => $exclude, 'reviewer' => 'sensitive'), true), 'new' => $tbl->getCount(array('exclude' => $exclude, 'created' => date('Y-m', time()), 'all' => 1), true));
     $active = $stats['general']['active'] ? $stats['general']['active'] : 1;
     $total = $stats['general']['total'] ? $stats['general']['total'] : 1;
     // Activity stats
     $objAA = new Activity($this->_db);
     $recentlyActive = $tbl->getCount(array('exclude' => $exclude, 'timed' => $pastMonth, 'active' => 1), true);
     $perc = round($recentlyActive * 100 / $active) . '%';
     $stats['activity'] = array('total' => $objAA->getActivityStats($include, 'total'), 'average' => $objAA->getActivityStats($include, 'average'), 'usage' => $perc);
     $stats['topActiveProjects'] = $objAA->getTopActiveProjects($exclude, 5, $publicOnly);
     // Collect team stats
     $objO = new Owner($this->_db);
     $multiTeam = $objO->getTeamStats($exclude, 'multi');
     $activeTeam = $objO->getTeamStats($exclude, 'registered');
     $invitedTeam = $objO->getTeamStats($exclude, 'invited');
     $multiProjectUsers = $objO->getTeamStats($exclude, 'multiusers');
     $teamTotal = $activeTeam + $invitedTeam;
     $perc = round($multiTeam * 100 / $total) . '%';
     $stats['team'] = array('total' => $teamTotal, 'average' => $objO->getTeamStats($exclude, 'average'), 'multi' => $perc, 'multiusers' => $multiProjectUsers);
     $stats['topTeamProjects'] = $objO->getTopTeamProjects($exclude, $limit, $publicOnly);
     // Collect files stats
     if ($lastLog) {
         $stats['files'] = $lastLog['files'];
     } else {
         // Get repo model
         require_once PATH_CORE . DS . 'components' . DS . 'com_projects' . DS . 'models' . DS . 'repo.php';
         // Compute
         $repo = new \Components\Projects\Models\Repo();
         $fTotal = $repo->getStats($validProjects);
         $fAverage = number_format($fTotal / $validCount, 0);
         $fUsage = $repo->getStats($validProjects, 'usage');
         $fDSpace = $repo->getStats($validProjects, 'diskspace');
         $fCommits = $repo->getStats($validProjects, 'commitCount');
         $pDSpace = $repo->getStats($validProjects, 'pubspace');
         $perc = round($fUsage * 100 / $active) . '%';
         $stats['files'] = array('total' => $fTotal, 'average' => $fAverage, 'usage' => $perc, 'diskspace' => \Hubzero\Utility\Number::formatBytes($fDSpace), 'commits' => $fCommits, 'pubspace' => \Hubzero\Utility\Number::formatBytes($pDSpace));
     }
     // Collect publication stats
     if ($publishing) {
         $objP = new \Components\Publications\Tables\Publication($this->_db);
         $objPV = new \Components\Publications\Tables\Version($this->_db);
         $prPub = $objP->getPubStats($include, 'usage');
         $perc = round($prPub * 100 / $total) . '%';
         $stats['pub'] = array('total' => $objP->getPubStats($include, 'total'), 'average' => $objP->getPubStats($include, 'average'), 'usage' => $perc, 'released' => $objP->getPubStats($include, 'released'), 'versions' => $objPV->getPubStats($include));
     }
     // Save weekly stats
     if ($saveLog) {
         $this->year = $thisYearNum;
         $this->month = $thisMonthNum;
         $this->week = $thisWeekNum;
         $this->processed = Date::toSql();
         $this->stats = json_encode($stats);
         $this->store();
     }
     $stats['updated'] = $updated ? $updated : NULL;
     return $stats;
 }
コード例 #9
0
 /**
  * Pull a list of records that were created within the time frame ($period)
  *
  * @param      object  $period     Time period to pull results for
  * @param      mixed   $limit      Number of records to pull
  * @param      integer $limitstart Start of records to pull
  * @param      array   $areas      Active area(s)
  * @param      array   $tagids     Array of tag IDs
  * @return     array
  */
 public function onWhatsnew($period, $limit = 0, $limitstart = 0, $areas = null, $tagids = array())
 {
     if (is_array($areas) && $limit) {
         if (!isset($areas[$this->_name]) && !in_array($this->_name, $areas)) {
             return array();
         }
     }
     // Do we have a time period?
     if (!is_object($period)) {
         return array();
     }
     $database = App::get('db');
     // Instantiate some needed objects
     $rr = new \Components\Publications\Tables\Publication($database);
     // Build query
     $filters = array('startdate' => $period->cStartDate, 'enddate' => $period->cEndDate, 'sortby' => 'date');
     if (count($tagids) > 0) {
         $filters['tag'] = $tagids;
     }
     if ($limit) {
         if ($this->_total != null) {
             $total = 0;
             $t = $this->_total;
             foreach ($t as $l) {
                 $total += $l;
             }
             if ($total == 0) {
                 return array();
             }
         }
         $filters['limit'] = $limit;
         $filters['start'] = $limitstart;
         // Get results
         $rows = $rr->getRecords($filters);
         // Did we get any results?
         if ($rows) {
             // Loop through the results and set each item's HREF
             foreach ($rows as $key => $row) {
                 $rows[$key]->text = NULL;
                 if ($row->alias) {
                     $rows[$key]->href = Route::url('index.php?option=com_publications&alias=' . $row->alias);
                 } else {
                     $rows[$key]->href = Route::url('index.php?option=com_publications&id=' . $row->id);
                 }
                 if ($row->abstract) {
                     $rows[$key]->text = $rows[$key]->abstract;
                 }
                 $rows[$key]->section = NULL;
                 $rows[$key]->area = $row->cat_name;
                 $rows[$key]->publish_up = $row->published_up;
             }
         }
         return $rows;
     } else {
         // Get a count
         $counts = array();
         // Execute count query
         $results = $rr->getCount($filters);
         return $results && is_array($results) ? count($results) : 0;
     }
 }
コード例 #10
0
 /**
  * Compute unique user stats from text logs
  *
  * @param   object   $job  \Components\Cron\Models\Job
  * @return  boolean
  */
 public function rollUserStats(\Components\Cron\Models\Job $job)
 {
     $database = \App::get('db');
     $pconfig = Component::params('com_publications');
     $numMonths = 1;
     $includeCurrent = false;
     require_once PATH_CORE . DS . 'components' . DS . 'com_publications' . DS . 'tables' . DS . 'publication.php';
     require_once PATH_CORE . DS . 'components' . DS . 'com_publications' . DS . 'tables' . DS . 'version.php';
     require_once PATH_CORE . DS . 'components' . DS . 'com_publications' . DS . 'models' . DS . 'log.php';
     // Get log model
     $modelLog = new \Components\Publications\Models\Log();
     $filters = array();
     $filters['sortby'] = 'date';
     $filters['limit'] = 0;
     $filters['start'] = 0;
     // Instantiate a publication object
     $rr = new \Components\Publications\Tables\Publication($database);
     // Get publications
     $pubs = $rr->getRecords($filters);
     // Compute and store stats for each publication
     foreach ($pubs as $publication) {
         $stats = $modelLog->digestLogs($publication->id, 'all', $numMonths, $includeCurrent);
     }
     return true;
 }
コード例 #11
0
ファイル: team.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Send invite email
  *
  * @param  integer 	$uid
  * @param  string 	$email
  * @param  string 	$code
  * @param  integer 	$role
  * @param  object 	$project
  *
  * @return boolean True on success
  */
 public function sendInviteEmail($uid = 0, $email = '', $code = '', $role = 0, $model = '', $option = 'com_projects')
 {
     $uid = $uid ? $uid : 0;
     $email = $email ? $email : User::get('email');
     if (!$email || !$uid && !$code) {
         return false;
     }
     $option = $option ? $option : $this->_option;
     $model = $model ? $model : $this->model;
     if (!$model->exists()) {
         return false;
     }
     $database = App::get('db');
     // Validate email
     $regex = '/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-]+)+/';
     if (!preg_match($regex, $email)) {
         return false;
     }
     // Set up email config
     $from = array('name' => Config::get('sitename') . ' ' . Lang::txt(strtoupper($option)), 'email' => Config::get('mailfrom'), 'multipart' => md5(date('U')));
     // Email message subject
     if ($model->isProvisioned()) {
         $objPub = new \Components\Publications\Tables\Publication($database);
         $pub = $objPub->getProvPublication($model->get('id'));
         if (!$pub || !$pub->id) {
             return false;
         }
         $subject = $uid ? Lang::txt('COM_PROJECTS_EMAIL_SUBJECT_ADDED_PROV') : Lang::txt('COM_PROJECTS_EMAIL_SUBJECT_INVITE_PROV');
     } else {
         $subject = $uid ? Lang::txt('COM_PROJECTS_EMAIL_SUBJECT_ADDED') . ' ' . $model->get('alias') : Lang::txt('COM_PROJECTS_EMAIL_SUBJECT_INVITE') . ' ' . $model->get('alias');
     }
     // Message body
     $eview = new \Hubzero\Mail\View(array('base_path' => PATH_CORE . DS . 'components' . DS . 'com_projects' . DS . 'site', 'name' => 'emails', 'layout' => 'invite_plain'));
     $eview->option = $option;
     $eview->project = $model;
     $eview->code = $code;
     $eview->email = $email;
     $eview->uid = $uid;
     $eview->role = $role;
     $eview->pub = isset($pub) ? $pub : '';
     $message['plaintext'] = $eview->loadTemplate(false);
     $message['plaintext'] = str_replace("\n", "\r\n", $message['plaintext']);
     // HTML email
     $eview->setLayout('invite_html');
     $message['multipart'] = $eview->loadTemplate();
     $message['multipart'] = str_replace("\n", "\r\n", $message['multipart']);
     if ($uid) {
         // Send HUB message
         if (Event::trigger('xmessage.onSendMessage', array('projects_member_added', $subject, $message, $from, array($uid), $option))) {
             return true;
         }
     } else {
         if (\Components\Projects\Helpers\Html::email($email, Config::get('sitename') . ': ' . $subject, $message, $from)) {
             return true;
         }
     }
     return false;
 }
コード例 #12
0
 /**
  * Sets the fields in this class with database data.
  *
  * @return boolean  True if succss and False otherwise
  */
 private function populateRDFData()
 {
     // Grabs database object
     $database = \App::get('db');
     $resource = new \Components\Publications\Tables\Version($database);
     $resource = $resource->getLastPubRelease($this->id);
     if (!$resource) {
         // Return if ID does not exist
         throw new Exception(Lang::txt('COM_PUBLICATIONS_FILE_NOT_FOUND'), 404);
         return false;
     }
     $this->setPaths();
     // Gets the author name
     $this->author_id = $resource->created_by;
     $this->created_by = User::getInstance($this->author_id)->name;
     // Set created date
     $this->date_created = $this->formatDate($resource->created);
     // Set description
     $this->intro = $resource->description;
     // Set title
     $this->title = $resource->title;
     // Set last modified date
     $this->date_modified = $this->formatDate($resource->modified);
     // Set published date
     $this->date_published = $this->formatDate($resource->published_up);
     // Set version ID
     $this->version_id = $resource->id;
     // Load the $types variable. In the form of array([type_id] => [type_name]).
     $resource = new \Components\Publications\Tables\Publication($database);
     $pub = $resource->getPublication($this->id);
     $type_id = $pub->category;
     $typesData = new \Components\Publications\Tables\Category($database);
     $allTypes = $typesData->getCategories(array('state' => 'all'));
     $this->types = array();
     foreach ($allTypes as $type) {
         $types[$type->id] = $type->name;
     }
     // Get the type name of this resource
     $this->type = $types[$type_id];
     // Get attachments
     $pubAttach = new \Components\Publications\Tables\Attachment($database);
     $attachments = $pubAttach->getAttachments($this->version_id);
     foreach ($attachments as $child) {
         $this->aggregates[$child->id]['parent_id'] = $this->id;
         $this->aggregates[$child->id]['title'] = basename($child->path);
         $this->aggregates[$child->id]['created'] = $this->formatDate($child->created);
         $this->aggregates[$child->id]['standalone'] = 0;
         $this->aggregates[$child->id]['path'] = $child->path;
         $this->aggregates[$child->id]['url'] = $this->componentURL . $this->id . '/serve?a=' . $child->id;
     }
     return true;
 }
コード例 #13
0
ファイル: links.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Edit citation view
  *
  * @return     string
  */
 public function editcite()
 {
     // Incoming
     $cid = Request::getInt('cid', 0);
     $pid = Request::getInt('pid', 0);
     $vid = Request::getInt('vid', 0);
     // Output HTML
     $view = new \Hubzero\Plugin\View(array('folder' => 'projects', 'element' => 'links', 'name' => 'selector', 'layout' => 'edit'));
     // Load classes
     $objP = new \Components\Publications\Tables\Publication($this->_database);
     $view->version = new \Components\Publications\Tables\Version($this->_database);
     // Load publication version
     $view->version->load($vid);
     if (!$view->version->id) {
         $this->setError(Lang::txt('PLG_PROJECTS_LINKS_SELECTOR_ERROR_NO_PUBID'));
     }
     // Get publication
     $view->publication = $objP->getPublication($view->version->publication_id, $view->version->version_number, $this->model->get('id'));
     if (!$view->publication) {
         $this->setError(Lang::txt('PLG_PROJECTS_LINKS_SELECTOR_ERROR_NO_PUBID'));
     }
     // On error
     if ($this->getError()) {
         // Output error
         $view = new \Hubzero\Plugin\View(array('folder' => 'projects', 'element' => 'files', 'name' => 'error'));
         $view->title = '';
         $view->option = $this->_option;
         $view->setError($this->getError());
         return $view->loadTemplate();
     }
     include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'tables' . DS . 'type.php';
     include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'tables' . DS . 'citation.php';
     // Load the object
     $view->row = new \Components\Citations\Tables\Citation($this->_database);
     $view->row->load($cid);
     // get the citation types
     $ct = new \Components\Citations\Tables\Type($this->_database);
     $view->types = $ct->getType();
     $view->option = $this->_option;
     $view->database = $this->_database;
     $view->model = $this->model;
     $view->uid = $this->_uid;
     $view->task = $this->_task;
     $view->ajax = Request::getInt('ajax', 0);
     // Get messages	and errors
     if ($this->getError()) {
         $view->setError($this->getError());
     }
     return $view->loadTemplate();
 }
コード例 #14
0
ファイル: tags.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Save block content
  *
  * @return  string  HTML
  */
 public function save($manifest = NULL, $blockId = 0, $pub = NULL, $actor = 0, $elementId = 0)
 {
     // Set block manifest
     if ($this->_manifest === NULL) {
         $this->_manifest = $manifest ? $manifest : self::getManifest();
     }
     // Make sure changes are allowed
     if ($this->_parent->checkFreeze($this->_manifest->params, $pub)) {
         return false;
     }
     // Load publication version
     $objP = new \Components\Publications\Tables\Publication($this->_parent->_db);
     if (!$objP->load($pub->id)) {
         $this->setError(Lang::txt('PLG_PROJECTS_PUBLICATIONS_PUBLICATION_NOT_FOUND'));
         return false;
     }
     $tagsHelper = new \Components\Publications\Helpers\Tags($this->_parent->_db);
     $tags = trim(Request::getVar('tags', '', 'post'));
     $tagsHelper->tag_object($actor, $pub->id, $tags, 1);
     // Reflect the update in curation record
     $this->_parent->set('_update', 1);
     // Save category
     $cat = Request::getInt('pubtype', 0);
     if ($cat && $pub->_category->id != $cat) {
         $objP->category = $cat;
         $objP->store();
     }
     return true;
 }