Example #1
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();
 }
Example #2
0
 /**
  * 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;
     }
 }
 /**
  * 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;
     }
 }