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