/**
  * Return data on a resource sub view (this will be some form of HTML)
  *
  * @param      object  $resource Current resource
  * @param      string  $option    Name of the component
  * @param      integer $miniview  View style
  * @return     array
  */
 public function onResourcesSub($resource, $option, $miniview = 0)
 {
     $arr = array('area' => $this->_name, 'html' => '', 'metadata' => '');
     // Get some needed libraries
     include_once __DIR__ . DS . 'resources.recommendation.php';
     // Set some filters for returning results
     $filters = array('id' => $resource->id, 'threshold' => $this->params->get('threshold', '0.21'), 'limit' => $this->params->get('display_limit', 10));
     $view = new \Hubzero\Plugin\View(array('folder' => $this->_type, 'element' => $this->_name, 'name' => 'browse'));
     // Instantiate a view
     if ($miniview) {
         $view->setLayout('mini');
     }
     // Pass the view some info
     $view->option = $option;
     $view->resource = $resource;
     // Get recommendations
     $database = App::get('db');
     $r = new ResourcesRecommendation($database);
     $view->results = $r->getResults($filters);
     if ($this->getError()) {
         $view->setError($this->getError());
     }
     // Return the output
     $arr['html'] = $view->loadTemplate();
     return $arr;
 }
Example #2
0
 /**
  * Initial render view
  *
  * @return  string
  */
 public static function render()
 {
     // Load language
     Lang::load('plg_time_weeklybar', __DIR__);
     // Create view
     $view = new \Hubzero\Plugin\View(array('folder' => 'time', 'element' => 'weeklybar', 'name' => 'overview'));
     return $view->loadTemplate();
 }
Example #3
0
 /**
  * Handles view events for latex files
  *
  * @param   \Hubzero\Filesystem\Collection  $collection  The file collection to view
  * @return  void
  **/
 public function onHandleView(\Hubzero\Filesystem\Collection $collection)
 {
     if (!$this->canHandle($collection)) {
         return false;
     }
     $file = $collection->findFirstWithExtension('tex');
     // Create view
     $view = new \Hubzero\Plugin\View(['folder' => 'handlers', 'element' => 'latex', 'name' => 'latex', 'layout' => 'view']);
     // Build path for storing temp previews
     $outputDir = PATH_APP . DS . trim($this->params->get('compile_dir', 'site/latex/compiled'), DS);
     $adapter = Manager::adapter('local', ['path' => $outputDir]);
     $uniqid = md5(uniqid());
     $temp = File::fromPath($uniqid . '.tex', $adapter);
     // Clean up data from Windows characters - important!
     $data = preg_replace('/[^(\\x20-\\x7F)\\x0A]*/', '', $file->read());
     // Store file locally
     $temp->write($data);
     // Build the command
     $command = DS . trim($this->params->get('texpath', '/usr/bin/pdflatex'), DS);
     $command .= ' -output-directory=' . $outputDir . ' -interaction=batchmode ' . escapeshellarg($temp->getAbsolutePath());
     // Exec and capture output
     exec($command, $out);
     $compiled = File::fromPath($uniqid . '.pdf', $adapter);
     $log = File::fromPath($uniqid . '.log', $adapter);
     if (!$compiled->size()) {
         $view->setError(Lang::txt('PLG_HANDLERS_LATEX_ERROR_COMPILE_TEX_FAILED'));
     }
     // Read log (to show in case of error)
     if ($log->size()) {
         $view->log = $log->read();
     }
     $view->compiled = $compiled;
     return $view;
 }
 /**
  * Return data on a publication sub view (this will be some form of HTML)
  *
  * @param      object  $publication 	Current publication
  * @param      string  $option    		Name of the component
  * @param      integer $miniview  		View style
  * @return     array
  */
 public function onPublicationSub($publication, $option, $miniview = 0)
 {
     $arr = array('html' => '', 'metadata' => '', 'name' => 'recommendations');
     // Check if our area is in the array of areas we want to return results for
     $areas = array('recommendations');
     if (!array_intersect($areas, $this->onPublicationSubAreas($publication)) && !array_intersect($areas, array_keys($this->onPublicationSubAreas($publication)))) {
         return false;
     }
     // Get some needed libraries
     include_once PATH_CORE . DS . 'plugins' . DS . 'publications' . DS . 'recommendations' . DS . 'publication.recommendation.php';
     // Set some filters for returning results
     $filters = array('id' => $publication->get('id'), 'threshold' => $this->params->get('threshold', '0.21'), 'limit' => $this->params->get('display_limit', 10));
     // Get recommendations
     $database = App::get('db');
     $r = new PublicationRecommendation($database);
     $results = $r->getResults($filters);
     $view = new \Hubzero\Plugin\View(array('folder' => $this->_type, 'element' => $this->_name, 'name' => 'browse'));
     // Instantiate a view
     if ($miniview) {
         $view->setLayout('mini');
     }
     // Pass the view some info
     $view->option = $option;
     $view->publication = $publication;
     $view->results = $results;
     if ($this->getError()) {
         $view->setError($this->getError());
     }
     // Return the output
     $arr['html'] = $view->loadTemplate();
     return $arr;
 }
Example #5
0
 /**
  * Render a tool session
  * 
  * @param   object  $tool
  * @param   object  $session
  * @param   boolean $readOnly
  * @return  string
  */
 public function onToolSessionView($tool, $session, $readOnly = false)
 {
     $us = App::get('session');
     $declared = Request::getWord('viewer');
     $viewer = $declared ? $declared : $us->get('tool_viewer');
     if (isset($session->rendered) && $session->rendered || $viewer && $viewer != $this->_name) {
         return;
     }
     if (!$this->canRender()) {
         return;
     }
     $session->rendered = $this->_name;
     if (!$declared) {
         //$us->set('tool_viewer', $this->_name);
     }
     $view = new \Hubzero\Plugin\View(array('folder' => $this->_type, 'element' => $this->_name, 'name' => 'session', 'layout' => 'default'));
     return $view->set('option', Request::getCmd('option', 'com_tools'))->set('controller', Request::getWord('controller', 'sessions'))->set('output', $session)->set('app', $tool)->set('readOnly', $readOnly)->set('params', $this->params)->loadTemplate();
 }
Example #6
0
 /**
  * Initial render view
  *
  * @return (string) view contents
  */
 public static function render()
 {
     // Load language
     Lang::load('plg_time_csv', __DIR__);
     $view = new \Hubzero\Plugin\View(array('folder' => 'time', 'element' => 'csv', 'name' => 'overview'));
     $view->hub_id = Request::getInt('hub_id', null);
     $view->start = Request::getCmd('start_date', Date::of(strtotime('today - 1 month'))->format('Y-m-d'));
     $view->end = Request::getCmd('end_date', Date::format('Y-m-d'));
     $records = Record::all()->where('date', '>=', $view->start)->where('date', '<=', Date::of(strtotime($view->end . ' + 1 day'))->format('Y-m-d'))->order('date', 'asc');
     if (isset($view->hub_id) && $view->hub_id > 0) {
         // @FIXME: is there a better way to do this?
         $records->whereIn('task_id', Task::select('id')->whereEquals('hub_id', $view->hub_id)->rows()->fieldsByKey('id'));
     }
     // Pass permissions to view
     $view->permissions = new Permissions('com_time');
     $view->records = $records->including('task.hub', 'user')->rows();
     return $view->loadTemplate();
 }
Example #7
0
 /**
  * Initial render view
  *
  * @return (string) view contents
  */
 public static function render()
 {
     // Load language
     Lang::load('plg_time_summary', __DIR__);
     // Create view
     $view = new \Hubzero\Plugin\View(array('folder' => 'time', 'element' => 'summary', 'name' => 'overview'));
     // Get vars from request
     $permissions = new Permissions('com_time');
     $view->hub_id = Request::getInt('hub_id', null);
     $view->task_id = Request::getInt('task_id', null);
     $view->start = Request::getCmd('start_date', Date::of(strtotime('today - 1 month'))->format('Y-m-d'));
     $view->end = Request::getCmd('end_date', Date::format('Y-m-d'));
     $view->hubs = array();
     $records = Record::where('date', '>=', Date::of($view->start . ' 00:00:00', Config::get('offset'))->toSql())->where('date', '<=', Date::of($view->end . ' 23:59:59', Config::get('offset'))->toSql());
     if (isset($view->task_id) && $view->task_id > 0) {
         $records->whereEquals('task_id', $view->task_id);
     } else {
         if (isset($view->hub_id) && $view->hub_id > 0) {
             $hub_id = $view->hub_id;
             $records->whereRelatedHas('task', function ($task) use($hub_id) {
                 $task->whereEquals('hub_id', $hub_id);
             });
         }
     }
     foreach ($records->including('task.hub', 'user') as $record) {
         if (isset($view->hubs[$record->task->hub_id])) {
             $view->hubs[$record->task->hub_id]['total'] += $record->time;
             if (isset($view->hubs[$record->task->hub_id]['tasks'][$record->task_id])) {
                 $view->hubs[$record->task->hub_id]['tasks'][$record->task_id]['total'] += $record->time;
                 $view->hubs[$record->task->hub_id]['tasks'][$record->task_id]['records'][] = $record;
             } else {
                 $view->hubs[$record->task->hub_id]['tasks'][$record->task_id] = ['name' => $record->task->name, 'total' => $record->time, 'records' => array($record)];
             }
         } else {
             if ($permissions->can('view.report', 'hub', $record->task->hub_id)) {
                 $view->hubs[$record->task->hub_id] = ['name' => $record->task->hub->name, 'tasks' => array($record->task_id => ['name' => $record->task->name, 'total' => $record->time, 'records' => [$record]]), 'total' => $record->time];
             }
         }
     }
     // Pass permissions to view
     $view->permissions = $permissions;
     return $view->loadTemplate();
 }
Example #8
0
 /**
  * Display block content
  *
  * @return  string  HTML
  */
 public function display($pub = NULL, $manifest = NULL, $viewname = 'edit', $blockId = 0)
 {
     // Set block manifest
     if ($this->_manifest === NULL) {
         $this->_manifest = $manifest ? $manifest : self::getManifest();
     }
     // Register blockId
     $this->_blockId = $blockId;
     if ($viewname == 'curator') {
         // Output HTML
         $view = new \Hubzero\Component\View(array('name' => 'curation', 'layout' => 'block'));
     } else {
         $name = $viewname == 'freeze' ? 'freeze' : 'draft';
         // Output HTML
         $view = new \Hubzero\Plugin\View(array('folder' => 'projects', 'element' => 'publications', 'name' => $name, 'layout' => 'wrapper'));
     }
     // Make sure we have attachments
     $pub->attachments();
     // Get block status
     $status = $pub->curation('blocks', $blockId, 'status');
     $status->review = $pub->curation('blocks', $blockId, 'review');
     // Get block element model
     $elModel = new \Components\Publications\Models\BlockElements($this->_parent->_db);
     // Properties object
     $master = new stdClass();
     $master->block = $this->_name;
     $master->blockId = $this->_blockId;
     $master->params = $this->_manifest->params;
     $master->props = $elModel->getActiveElement($status->elements, $status->review);
     $view->manifest = $this->_manifest;
     $view->content = self::buildContent($pub, $viewname, $status, $master);
     $view->pub = $pub;
     $view->active = $this->_name;
     $view->step = $blockId;
     $view->showControls = isset($master->params->collapse_elements) && $master->params->collapse_elements == 1 ? 3 : 2;
     $view->status = $status;
     $view->master = $master;
     if ($this->getError()) {
         $view->setError($this->getError());
     }
     return $view->loadTemplate();
 }
Example #9
0
		<input type="hidden" name="step" value="<?php 
echo $this->step;
?>
" />
		<input type="hidden" name="active" value="publications" />
		<input type="hidden" name="action" value="apply" />
		<input type="hidden" name="move" value="continue" />
	</fieldset>
	<p class="requirement"><?php 
echo Lang::txt('PLG_PROJECTS_TEAM_SELECTOR_SELECT_FROM_TEAM');
?>
</p>
	<div id="content-selector" class="content-selector">
		<?php 
// Show files
$view = new \Hubzero\Plugin\View(array('folder' => 'projects', 'element' => 'team', 'name' => 'selector', 'layout' => 'selector'));
$view->option = $this->option;
$view->model = $this->model;
$view->selected = $selected;
$view->publication = $this->publication;
$view->team = $this->team;
echo $view->loadTemplate();
?>
	</div>
	</form>
	<p class="newauthor-question"><span><?php 
echo Lang::txt('PLG_PROJECTS_TEAM_SELECTOR_AUTHOR_NOT_PART_OF_TEAM');
?>
 <a href="<?php 
echo $newauthorUrl;
?>
Example #10
0
    $element = $this->publication->curation('blocks', $this->blockId, 'elements', $this->element);
    $params = $element->params;
    $max = $params->max;
    $min = $params->min;
    ?>
			<input type="hidden" id="maxitems" name="maxitems" value="<?php 
    echo $max;
    ?>
" />
			<input type="hidden" id="minitems" name="minitems" value="<?php 
    echo $min;
    ?>
" />
			<?php 
    // Show selection
    $view = new \Hubzero\Plugin\View(array('folder' => 'projects', 'element' => 'publications', 'name' => 'selector', 'layout' => $this->block));
    $view->option = $this->option;
    $view->project = $this->project;
    $view->database = $this->database;
    $view->manifest = $manifest;
    $view->publication = $this->publication;
    $view->url = Route::url($this->publication->link('edit'));
    $view->display();
    $task = 'apply';
}
?>
		<input type="hidden" name="action" value="<?php 
echo $task;
?>
" />
	</form>
Example #11
0
 /**
  * Event call to get content for public project page
  *
  * @return
  */
 public function onProjectPublicList($model)
 {
     if (!$model->exists() || !$model->access('content') || !$model->isPublic()) {
         return false;
     }
     if (!$model->params->get('notes_public', 0)) {
         return false;
     }
     $view = new \Hubzero\Plugin\View(array('folder' => 'projects', 'element' => 'notes', 'name' => 'publist'));
     require_once PATH_CORE . DS . 'components' . DS . 'com_projects' . DS . 'tables' . DS . 'publicstamp.php';
     $database = App::get('db');
     $objSt = new \Components\Projects\Tables\Stamp($database);
     $view->items = $objSt->getPubList($model->get('id'), 'notes');
     $view->page = new \Components\Wiki\Tables\Page($database);
     $view->model = $model;
     return $view->loadTemplate();
 }
Example #12
0
 /**
  * View of item
  *
  * @return	   string
  */
 public function item()
 {
     // Incoming
     $todoid = $this->_todoid ? $this->_todoid : Request::getInt('todoid', 0);
     $layout = $this->_task == 'edit' || $this->_task == 'new' ? 'edit' : 'default';
     // Check permission
     if ($this->_task == 'edit' && !$this->model->access('content')) {
         throw new Exception(Lang::txt('ALERTNOTAUTH'), 403);
         return;
     }
     $view = new \Hubzero\Plugin\View(array('folder' => $this->_type, 'element' => $this->_name, 'name' => 'item', 'layout' => $layout));
     $view->option = $this->option;
     $view->todo = $this->todo;
     $view->params = $this->model->params;
     $view->model = $this->model;
     // Get team members (to assign items to)
     $objO = $this->model->table('Owner');
     $view->team = $objO->getOwners($this->model->get('id'), $tfilters = array('status' => 1));
     if (isset($this->entry) && is_object($this->entry)) {
         $view->row = $this->entry;
     } else {
         $view->row = $this->todo->entry($todoid);
     }
     if (!$view->row->exists() && $this->_task != 'new') {
         return $this->page();
     }
     // Append breadcrumbs
     Pathway::append(stripslashes(\Hubzero\Utility\String::truncate($view->row->get('content'), 40)), Route::url($this->model->link('todo') . '&action=view&todoid=' . $todoid));
     $view->uid = $this->_uid;
     $view->title = $this->_area['title'];
     $view->list = Request::getVar('list', '');
     $view->ajax = Request::getVar('ajax', 0);
     return $view->loadTemplate();
 }
Example #13
0
 /**
  * Draw attachment
  *
  * @return  HTML string
  */
 public function drawAttachment($data, $params)
 {
     // Output HTML
     $view = new \Hubzero\Plugin\View(array('folder' => 'projects', 'element' => 'publications', 'name' => 'attachments', 'layout' => $this->_name));
     $view->data = $data;
     $view->params = $params;
     if ($this->getError()) {
         $view->setError($this->getError());
     }
     return $view->loadTemplate();
 }
Example #14
0
 /**
  * Manage connections to outside services
  *
  * @param   string  $service   Service name (google/dropbox)
  * @param   string  $callback  URL to return to after authorization
  * @return  string
  */
 protected function _connect($service = '', $callback = '')
 {
     // Incoming
     $service = $service ? $service : Request::getVar('service', '');
     $reauth = Request::getInt('reauth', 0);
     $removeData = Request::getInt('removedata', 1);
     // Build pub url
     $url = Route::url($this->model->link('files'));
     // Build return URL
     $return = $callback ? $callback : $url . '?action=connect';
     // Handle authentication request for service
     if ($service) {
         $configs = $this->_connect->getConfigs($service, false);
         if ($this->_task == 'disconnect') {
             if ($this->_connect->disconnect($service, $removeData)) {
                 $this->_msg = Lang::txt('PLG_PROJECTS_FILES_DISCONNECT_SUCCESS') . ' ' . $configs['servicename'];
             } else {
                 $this->setError($this->_connect->getError());
             }
             // Redirect to connect screen
             App::redirect(Route::url($this->model->link('files') . '&action=connect'));
             return;
         } elseif (!$this->_connect->makeConnection($service, $reauth, $return)) {
             $this->setError($this->_connect->getError());
         } else {
             // Successful authentication
             if (!$this->_connect->afterConnect($service, $this->_uid)) {
                 $this->setError($this->_connect->getError());
             } else {
                 $this->_msg = Lang::txt('PLG_PROJECTS_FILES_CONNECT_SUCCESS');
             }
         }
         // Refresh info
         $this->_connect->setConfigs();
     }
     // Output HTML
     $view = new \Hubzero\Plugin\View(array('folder' => 'projects', 'element' => 'files', 'name' => 'connect'));
     $view->option = $this->_option;
     $view->database = $this->_database;
     $view->model = $this->model;
     $view->uid = $this->_uid;
     $view->url = $url;
     $view->title = $this->_area['title'];
     $view->services = $this->_connect->getServices();
     $view->connect = $this->_connect;
     // Get refreshed params
     $this->model->reloadProject();
     $view->params = new \Hubzero\Config\Registry($this->model->table()->params);
     // Get connection details for user
     $member = $this->model->member(true);
     $view->oparams = new \Hubzero\Config\Registry($member->params);
     // Get messages	and errors
     $view->msg = $this->_msg;
     if ($this->getError()) {
         $view->setError($this->getError());
     }
     return $view->loadTemplate();
 }
Example #15
0
 /**
  * Return data on a publication sub view (this will be some form of HTML)
  *
  * @param      object  $publication 	Current publication
  * @param      string  $option    		Name of the component
  * @param      integer $miniview  		View style
  * @return     array
  */
 public function onPublicationSub($publication, $option, $miniview = 0)
 {
     $arr = array('html' => '', 'metadata' => '');
     // Check if our area is in the array of areas we want to return results for
     $areas = array('related');
     if (!array_intersect($areas, $this->onPublicationSubAreas($publication)) && !array_intersect($areas, array_keys($this->onPublicationSubAreas($publication)))) {
         return false;
     }
     $database = App::get('db');
     // Build the query that checks topic pages
     $sql1 = "SELECT v.id, v.page_id AS pageid, MAX(v.version) AS version, w.title, w.pagename AS alias, v.pagetext AS abstract,\n\t\t\t\t\tNULL AS category, NULL AS published, NULL AS publish_up, w.scope, w.rating, w.times_rated, w.ranking, 'wiki' AS class, 'Topic' AS section\n\t\t\t\tFROM `#__wiki_pages` AS w\n\t\t\t\tJOIN `#__wiki_versions` AS v ON w.id=v.page_id\n\t\t\t\tJOIN `#__wiki_links` AS wl ON wl.page_id=w.id\n\t\t\t\tWHERE v.approved=1 AND wl.scope='publication' AND wl.scope_id=" . $database->quote($publication->id);
     if (!User::isGuest()) {
         if (User::authorise('com_resources', 'manage') || User::authorise('com_groups', 'manage')) {
             $sql1 .= '';
         } else {
             $ugs = \Hubzero\User\Helper::getGroups(User::get('id'), 'members');
             $groups = array();
             $cns = array();
             if ($ugs && count($ugs) > 0) {
                 foreach ($ugs as $ug) {
                     $cns[] = $database->quote($ug->cn);
                     $groups[] = $database->quote($ug->gidNumber);
                 }
             }
             $g = implode(",", $groups);
             $c = implode(",", $cns);
             $sql1 .= "AND (w.access!=1 OR (w.access=1 AND ((w.scope=" . $database->quote('group') . " AND w.scope_id IN ({$g})) OR w.created_by=" . $database->quote(User::get('id')) . "))) ";
         }
     } else {
         $sql1 .= "AND w.access!=1 ";
     }
     $sql1 .= "GROUP BY pageid ORDER BY ranking DESC, title LIMIT 10";
     // Initiate a helper class
     $model = new \Components\Publications\Models\Publication($publication);
     $tags = $model->getTags();
     // Get version authors
     $authors = isset($publication->_authors) ? $publication->_authors : array();
     // Build the query that get publications related by tag
     $sql2 = "SELECT DISTINCT r.publication_id as id, NULL AS pageid, r.id AS version,\n\t\t\t\tr.title, C.alias, r.abstract, C.category, r.state as published,\n\t\t\t\tr.published_up, NULL AS scope, C.rating, C.times_rated, C.ranking,\n\t\t\t\trt.alias AS class, rt.name AS section" . "\n FROM #__publications as C, #__publication_categories AS rt, #__publication_versions AS r " . "\n JOIN #__tags_object AS a ON r.publication_id=a.objectid AND a.tbl='publications'" . "\n JOIN #__publication_authors AS PA ON PA.publication_version_id=r.id " . "\n WHERE C.id=r.publication_id ";
     if ($tags) {
         $tquery = array(0);
         foreach ($tags as $tagg) {
             $tquery[] = $database->quote($tagg->get('id'));
         }
         $sql2 .= " AND ( a.tagid IN (" . implode(',', $tquery) . ")";
         $sql2 .= count($authors) > 0 ? " OR " : "";
     }
     if (count($authors) > 0) {
         $aquery = '';
         foreach ($authors as $author) {
             $aquery .= "'" . $author->user_id . "',";
         }
         $aquery = substr($aquery, 0, strlen($aquery) - 1);
         $sql2 .= $tags ? "" : " AND ( ";
         $sql2 .= " PA.user_id IN (" . $aquery . ")";
     }
     $sql2 .= $tags || count($authors) > 0 ? ")" : "";
     $sql2 .= " AND r.publication_id !=" . $publication->id;
     $sql2 .= " AND C.category = rt.id AND C.category!=8 ";
     $sql2 .= "AND r.access=0 ";
     $sql2 .= "AND r.state=1 ";
     $sql2 .= "GROUP BY r.publication_id ORDER BY r.ranking LIMIT 10";
     // Build the final query
     $query = "SELECT k.* FROM (({$sql1}) UNION ({$sql2})) AS k ORDER BY ranking DESC LIMIT 10";
     // Execute the query
     $database->setQuery($query);
     $related = $database->loadObjectList();
     // Instantiate a view
     if ($miniview) {
         $view = new \Hubzero\Plugin\View(array('folder' => 'publications', 'element' => 'related', 'name' => 'browse', 'layout' => 'mini'));
     } else {
         $view = new \Hubzero\Plugin\View(array('folder' => 'publications', 'element' => 'related', 'name' => 'browse'));
     }
     // Pass the view some info
     $view->option = $option;
     $view->publication = $publication;
     $view->related = $related;
     if ($this->getError()) {
         $view->setError($this->getError());
     }
     // Return the output
     $arr['html'] = $view->loadTemplate();
     // Return the an array of content
     return $arr;
 }
Example #16
0
 /**
  * Create database
  *
  * @return     array
  */
 public function act_create()
 {
     // Check permission
     if (!$this->model->access('content')) {
         throw new Exception(Lang::txt('ALERTNOTAUTH'), 403);
         return;
     }
     // Incoming
     $db_id = Request::getInt('db_id', false);
     // Get project path
     $path = \Components\Projects\Helpers\Html::getProjectRepoPath($this->model->get('alias'));
     $list = array();
     $error = false;
     if (file_exists($path) && is_dir($path)) {
         chdir($path);
         exec($this->gitpath . ' ls-files --exclude-standard |grep ".csv"', $list);
         sort($list);
     } else {
         $error = Lang::txt('PLG_PROJECTS_DATABASES_MISSING_REPO');
     }
     // Get project database object
     $objPD = new \Components\Projects\Tables\Database($this->_database);
     // Get database list
     $used_files = $objPD->getUsedItems($this->model->get('id'));
     $files = array();
     foreach ($list as $l) {
         $info = array();
         chdir($path);
         exec($this->gitpath . ' log --date=local --pretty=format:%f"|#|"%H"|#|"%ad%n "' . $l . '"|head -1', $info);
         $info = explode('|#|', $info[0]);
         $file = pathinfo($l);
         if (!in_array($l, $used_files)) {
             $files[$file['dirname']][] = array('name' => $file['basename'], 'hash' => $info[1], 'date' => $info[2]);
         }
     }
     // Output HTML
     $view = new \Hubzero\Plugin\View(array('folder' => 'projects', 'element' => 'databases', 'name' => 'create'));
     $view->model = $this->model;
     $view->option = $this->_option;
     $view->files = $files;
     $view->msg = NULL;
     if ($error) {
         $view->setError($error);
     }
     // Get project database object
     $objPD = new \Components\Projects\Tables\Database($this->_database);
     if ($objPD->loadRecord($db_id)) {
         $view->db_id = $db_id;
         $view->dir = trim($objPD->source_dir, '/');
         $view->file = trim($objPD->source_file, '/');
         $view->title = $objPD->title;
         $view->desc = $objPD->description;
     }
     return array('html' => $view->loadTemplate());
 }
Example #17
0
 /**
  * Set local password
  *
  * @return void - redirect to members account page
  */
 private function setlocalpass()
 {
     // Logged in?
     if ($this->user->get('guest')) {
         App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode(Route::url('index.php?option=' . $this->option . '&task=myaccount&active=account&action=setlocalpass'))), Lang::txt('You must be a logged in to access this area.'), 'warning');
         return;
     }
     // Get the token from the user state variable
     $token = User::getState($this->option . 'token');
     // First check to make sure they're not trying to jump to this page without first verifying their token
     if (is_null($token)) {
         // Tsk tsk, no sneaky business
         App::redirect(Route::url('index.php?option=' . $this->option . '&id=' . $this->user->get('id') . '&active=account&task=sendtoken'), Lang::txt('You must first verify your email address by inputting the token.'), 'error');
         return;
     }
     // Get the password input
     $password1 = Request::getVar('password1', null, 'post', 'string', JREQUEST_ALLOWRAW);
     $password2 = Request::getVar('password2', null, 'post', 'string', JREQUEST_ALLOWRAW);
     $change = Request::getVar('change', '', 'post');
     // Create the view
     $view = new \Hubzero\Plugin\View(array('folder' => 'members', 'element' => 'account', 'name' => 'setlocalpassword', 'layout' => 'setlocalpass'));
     // Add a few more variables to the view
     $view->option = $this->option;
     $view->id = $this->user->get('id');
     // Get the password rules
     $password_rules = \Hubzero\Password\Rule::getRules();
     // Get the password rule descriptions
     $view->password_rules = array();
     foreach ($password_rules as $rule) {
         if (!empty($rule['description'])) {
             $view->password_rules[] = $rule['description'];
         }
     }
     // Blank form request (no data submitted)
     if (empty($change)) {
         $view->notifications = $this->getPluginMessage() ? $this->getPluginMessage() : array();
         return $view->loadTemplate();
     }
     // Check for request forgeries
     Request::checkToken();
     // Load some needed libraries
     jimport('joomla.user.helper');
     // Initiate profile classs
     $profile = new \Hubzero\User\Profile();
     $profile->load($this->user->get('id'));
     // Fire the onBeforeStoreUser trigger
     Event::trigger('user.onBeforeStoreUser', array($this->user->getProperties(), false));
     // Validate the password against password rules
     if (!empty($password1)) {
         $msg = \Hubzero\Password\Rule::validate($password1, $password_rules, $profile->get('username'));
     } else {
         $msg = array();
     }
     // Verify password
     $passrules = false;
     if (!$password1 || !$password2) {
         $this->setError(Lang::txt('MEMBERS_PASS_MUST_BE_ENTERED_TWICE'));
     } elseif ($password1 != $password2) {
         $this->setError(Lang::txt('MEMBERS_PASS_NEW_CONFIRMATION_MISMATCH'));
     } elseif (!empty($msg)) {
         $this->setError(Lang::txt('Password does not meet site password requirements. Please choose a password meeting all the requirements listed.'));
         $passrules = true;
     }
     // Were there any errors?
     if ($this->getError()) {
         $change = array();
         $change['_missing']['password'] = $this->getError();
         if (!empty($msg) && $passrules) {
             //$change = $msg;
         }
         if (Request::getInt('no_html', 0)) {
             echo json_encode($change);
             exit;
         } else {
             $view->setError($this->getError());
             return $view->loadTemplate();
         }
     }
     // No errors, so let's move on - encrypt the password and update the profile
     $result = \Hubzero\User\Password::changePassword($profile->get('uidNumber'), $password1);
     // Save the changes
     if (!$result) {
         $view->setError(Lang::txt('MEMBERS_PASS_CHANGE_FAILED'));
         return $view->loadTemplate();
     }
     // Fire the onAfterStoreUser trigger
     Event::trigger('user.onAfterStoreUser', array($this->user->getProperties(), false, null, $this->getError()));
     // Flush the variables from the session
     User::setState($this->option . 'token', null);
     // Redirect
     if (Request::getInt('no_html', 0)) {
         echo json_encode(array("success" => true, "redirect" => Route::url($this->member->getLink() . '&active=account')));
         exit;
     } else {
         // Redirect user to confirm view page
         App::redirect(Route::url($this->member->getLink() . '&active=account'), Lang::txt('Password reset successful'), 'passed');
     }
     return;
 }
Example #18
0
 /**
  * Build panel content
  *
  * @return  string  HTML
  */
 public function buildContent($pub = NULL, $viewname = 'edit')
 {
     $name = $viewname == 'freeze' || $viewname == 'curator' ? 'freeze' : 'draft';
     // Get selector styles
     \Hubzero\Document\Assets::addPluginStylesheet('projects', 'publications', 'selector');
     // Output HTML
     $view = new \Hubzero\Plugin\View(array('folder' => 'projects', 'element' => 'publications', 'name' => $name, 'layout' => 'license'));
     $view->pub = $pub;
     $view->manifest = $this->_manifest;
     $view->step = $this->_blockId;
     $objL = new \Components\Publications\Tables\License($this->_parent->_db);
     // Get selected license
     $view->license = $objL->getPubLicense($pub->version_id);
     $view->selections = $objL->getBlockLicenses($this->_manifest, $view->license);
     // Pre-select single available license
     if (!$view->license && count($view->selections) == 1) {
         $view->license = new \Components\Publications\Tables\License($this->_parent->_db);
         $view->license->load($view->selections[0]->id);
     }
     if ($this->getError()) {
         $view->setError($this->getError());
     }
     return $view->loadTemplate();
 }
Example #19
0
				<?php 
    echo $this->escape(stripslashes($this->course->offering()->section()->get('title')));
    ?>
			</span>
		</p>
	</header><!-- / #content-header -->

	<div class="innerwrap">
		<div id="page_container">
<?php 
}
?>

<?php 
if (!$this->course->offering()->access('view') && !$sparams->get('preview', 0)) {
    $view = new \Hubzero\Plugin\View(array('folder' => 'courses', 'element' => 'outline', 'name' => 'shared', 'layout' => '_not_enrolled'));
    $view->set('course', $this->course)->set('option', 'com_courses')->set('message', Lang::txt('COM_COURSES_ENROLLMENT_REQUIRED'));
    echo $view;
} else {
    if ($this->course->offering()->section()->expired() && !$sparams->get('preview', 0)) {
        ?>
			<div id="offering-introduction">
				<div class="instructions">
					<p class="warning"><?php 
        echo Lang::txt('COM_COURSES_SECTION_EXPIRED');
        ?>
</p>
				</div><!-- / .instructions -->
				<div class="questions">
					<p><strong><?php 
        echo Lang::txt('COM_COURSES_WHERE_TO_LEARN_MORE');
Example #20
0
 /**
  * Return data on a course view (this will be some form of HTML)
  *
  * @param   object   $course    Current course
  * @param   object   $offering  Name of the component
  * @param   boolean  $describe  Return plugin description only?
  * @return  object
  */
 public function onCourse($course, $offering, $describe = false)
 {
     $response = with(new \Hubzero\Base\Object())->set('name', $this->_name)->set('title', Lang::txt('PLG_COURSES_' . strtoupper($this->_name)))->set('description', Lang::txt('PLG_COURSES_' . strtoupper($this->_name) . '_BLURB'))->set('default_access', $this->params->get('plugin_access', 'members'))->set('display_menu_tab', true)->set('icon', 'f012');
     if ($describe) {
         return $response;
     }
     if (!($active = Request::getVar('active'))) {
         Request::setVar('active', $active = $this->_name);
     }
     if ($response->get('name') != $active) {
         return $response;
     }
     // Check to see if user is member and plugin access requires members
     if (!$course->offering()->section()->access('view')) {
         $view = new \Hubzero\Plugin\View(array('folder' => 'courses', 'element' => 'outline', 'name' => 'shared', 'layout' => '_not_enrolled'));
         $view->set('course', $course)->set('option', 'com_courses')->set('message', 'You must be enrolled to utilize the progress feature.');
         $response->set('html', $view->__toString());
         return $response;
     }
     $this->member = $course->offering()->section()->member(User::get('id'));
     $this->course = $course;
     $this->base = $course->offering()->link();
     $this->db = App::get('db');
     // Instantiate a vew
     $this->view = $this->view('student', 'report');
     $this->view->course = $course;
     $this->view->member = $this->member;
     $this->view->option = 'com_courses';
     $this->view->base = $this->base;
     switch (Request::getWord('action')) {
         case 'assessmentdetails':
             $this->assessmentdetails();
             break;
         case 'getprogressrows':
             $this->getprogressrows();
             break;
         case 'getprogressdata':
             $this->getprogressdata();
             break;
         case 'getgradebookdata':
             $this->getgradebookdata();
             break;
         case 'getreportsdata':
             $this->getreportsdata();
             break;
         case 'exportcsv':
             $this->exportcsv();
             break;
         case 'downloadresponses':
             $this->downloadresponses();
             break;
         case 'savegradebookitem':
             $this->savegradebookitem();
             break;
         case 'deletegradebookitem':
             $this->deletegradebookitem();
             break;
         case 'savegradebookentry':
             $this->savegradebookentry();
             break;
         case 'resetgradebookentry':
             $this->resetgradebookentry();
             break;
         case 'policysave':
             $this->policysave();
             break;
         case 'restoredefaults':
             $this->restoredefaults();
             break;
         default:
             $this->progress();
             break;
     }
     $response->set('html', $this->view->loadTemplate());
     // Return the output
     return $response;
 }
Example #21
0
 /**
  * Return data on a resource view (this will be some form of HTML)
  *
  * @param      object  	$publication 	Current publication
  * @param      string  	$option    		Name of the component
  * @param      array   	$areas     		Active area(s)
  * @param      string  	$rtrn      		Data to be returned
  * @param      string 	$version 		Version name
  * @param      boolean 	$extended 		Whether or not to show panel
  * @return     array
  */
 public function onPublication($publication, $option, $areas, $rtrn = 'all', $version = 'default', $extended = true)
 {
     $arr = array('html' => '', 'metadata' => '');
     // Check if our area is in the array of areas we want to return results for
     if (is_array($areas)) {
         if (!array_intersect($areas, $this->onPublicationAreas($publication)) && !array_intersect($areas, array_keys($this->onPublicationAreas($publication)))) {
             $rtrn = 'metadata';
         }
     }
     if (!$publication->_category->_params->get('plg_usage') || !$extended) {
         return $arr;
     }
     // Temporarily display only metadata
     $rtrn = 'metadata';
     // Check if we have a needed database table
     $database = App::get('db');
     $tables = $database->getTableList();
     $table = $database->getPrefix() . 'publication_stats';
     if ($publication->alias) {
         $url = Route::url('index.php?option=' . $option . '&alias=' . $publication->alias . '&active=usage');
     } else {
         $url = Route::url('index.php?option=' . $option . '&id=' . $publication->id . '&active=usage');
     }
     if (!in_array($table, $tables)) {
         $arr['html'] = '<p class="error">' . Lang::txt('PLG_PUBLICATION_USAGE_MISSING_TABLE') . '</p>';
         $arr['metadata'] = '<p class="usage"><a href="' . $url . '">' . Lang::txt('PLG_PUBLICATION_USAGE_DETAILED') . '</a></p>';
         return $arr;
     }
     // Get/set some variables
     $dthis = Request::getVar('dthis', date('Y') . '-' . date('m'));
     $period = Request::getInt('period', $this->params->get('period', 14));
     include_once PATH_CORE . DS . 'components' . DS . $option . DS . 'tables' . DS . 'stats.php';
     require_once PATH_CORE . DS . 'components' . DS . $option . DS . 'helpers' . DS . 'usage.php';
     $stats = new \Components\Publications\Tables\Stats($database);
     $stats->loadStats($publication->id, $period, $dthis);
     // Are we returning HTML?
     if ($rtrn == 'all' || $rtrn == 'html') {
         \Hubzero\Document\Assets::addComponentStylesheet('com_usage');
         // Instantiate a view
         $view = new \Hubzero\Plugin\View(array('folder' => 'publications', 'element' => 'usage', 'name' => 'browse'));
         // Get usage helper
         $view->helper = new \Components\Publications\Helpers\Usage($database, $publication->id, $publication->base);
         // Pass the view some info
         $view->option = $option;
         $view->publication = $publication;
         $view->stats = $stats;
         $view->chart_path = $this->params->get('chart_path', '');
         $view->map_path = $this->params->get('map_path', '');
         $view->dthis = $dthis;
         $view->period = $period;
         if ($this->getError()) {
             $view->setError($this->getError());
         }
         // Return the output
         $arr['html'] = $view->loadTemplate();
     }
     if ($rtrn == 'metadata') {
         $stats->loadStats($publication->id, $period);
         if ($stats->users) {
             $action = $publication->base == 'files' ? '%s download(s)' : '%s view(s)';
             $arr['metadata'] = '<p class="usage">' . Lang::txt('%s user(s)', $stats->users);
             $arr['metadata'] .= $stats->downloads ? ' | ' . Lang::txt($action, $stats->downloads) : '';
             $arr['metadata'] .= '</p>';
         }
     }
     if ($stats->users) {
         $arr['name'] = 'usage';
         $arr['count'] = $stats->users;
     }
     return $arr;
 }
Example #22
0
 /**
  * Build panel content
  *
  * @return  string  HTML
  */
 public function buildContent($pub = NULL, $viewname = 'edit')
 {
     $name = $viewname == 'freeze' || $viewname == 'curator' ? 'freeze' : 'draft';
     // Output HTML
     $view = new \Hubzero\Plugin\View(array('folder' => 'projects', 'element' => 'publications', 'name' => $name, 'layout' => 'citations'));
     // Get selector styles
     \Hubzero\Document\Assets::addPluginStylesheet('projects', 'links');
     \Hubzero\Document\Assets::addPluginStylesheet('projects', 'files', 'selector');
     \Hubzero\Document\Assets::addPluginStylesheet('projects', 'publications', 'selector');
     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);
     }
     $view->pub = $pub;
     $view->manifest = $this->_manifest;
     $view->step = $this->_blockId;
     if ($this->getError()) {
         $view->setError($this->getError());
     }
     return $view->loadTemplate();
 }
Example #23
0
 /**
  * Compiles PDF/image preview for any kind of file
  *
  * @return  string
  */
 public function compile()
 {
     // Combine file and folder data
     $items = $this->getCollection();
     // Incoming
     $download = Request::getInt('download', 0);
     // Check that we have compile enabled
     // @FIXME: why are latex and compiled preview tied together?
     //         presumedly we are also 'compiling' pdfs?
     if (!$this->params->get('latex')) {
         $this->setError(Lang::txt('PLG_PROJECTS_FILES_COMPILE_NOTALLOWED'));
         return;
     }
     // Output HTML
     $view = new \Hubzero\Plugin\View(['folder' => 'projects', 'element' => 'files', 'name' => 'connected', 'layout' => 'compiled']);
     // Make sure we have an item
     if (count($items) == 0) {
         $view->setError(Lang::txt('PLG_PROJECTS_FILES_ERROR_NO_FILES_TO_COMPILE'));
         $view->loadTemplate();
         return;
     }
     // We can only handle one file at a time
     $file = $items->first();
     // Build path for storing temp previews
     $imagePath = trim($this->model->config()->get('imagepath', '/site/projects'), DS);
     $outputDir = DS . $imagePath . DS . strtolower($this->model->get('alias')) . DS . 'compiled';
     // Make sure output dir exists
     if (!is_dir(PATH_APP . $outputDir)) {
         if (!Filesystem::makeDirectory(PATH_APP . $outputDir)) {
             $this->setError(Lang::txt('PLG_PROJECTS_FILES_UNABLE_TO_CREATE_UPLOAD_PATH'));
             return;
         }
     }
     // Get LaTeX helper
     $compiler = new \Components\Projects\Helpers\Compiler();
     // Tex compiler path
     $texPath = DS . trim($this->params->get('texpath'), DS);
     // Set view args and defaults
     $view->file = $file;
     $view->oWidth = '780';
     $view->oHeight = '460';
     $view->url = $this->model->link('files');
     $cExt = 'pdf';
     // Tex file?
     $tex = $compiler->isTexFile($file->getName());
     // Build temp name
     $tempBase = $tex ? 'temp__' . \Components\Projects\Helpers\Html::takeOutExt($file->getName()) : $file->getName();
     $tempBase = str_replace(' ', '_', $tempBase);
     $view->data = $file->isImage() ? NULL : $file->read();
     // LaTeX file?
     if ($tex && !empty($view->data)) {
         // Clean up data from Windows characters - important!
         $view->data = preg_replace('/[^(\\x20-\\x7F)\\x0A]*/', '', $view->data);
         // Store file locally
         $tmpfile = PATH_APP . $outputDir . DS . $tempBase;
         file_put_contents($tmpfile, $view->data);
         // Compile and get path to PDF
         $contentFile = $compiler->compileTex($tmpfile, $view->data, $texPath, PATH_APP . $outputDir, 1, $tempBase);
         // Read log (to show in case of error)
         $logFile = $tempBase . '.log';
         if (file_exists(PATH_APP . $outputDir . DS . $logFile)) {
             $view->log = Filesystem::read(PATH_APP . $outputDir . DS . $logFile);
         }
         if (!$contentFile) {
             $this->setError(Lang::txt('PLG_PROJECTS_FILES_ERROR_COMPILE_TEX_FAILED'));
         }
         $cType = Filesystem::mimetype(PATH_APP . $outputDir . DS . $contentFile);
     } else {
         // Make sure we can handle preview of this type of file
         if ($file->hasExtension('pdf') || $file->isImage() || !$file->isBinary()) {
             $origin = $this->connection->provider->alias . '://' . $file->getPath();
             $dest = 'compiled://' . $tempBase;
             // Do the copy
             Manager::adapter('local', ['path' => PATH_APP . $outputDir . DS], 'compiled');
             Manager::copy($origin, $dest);
             $contentFile = $tempBase;
         }
     }
     // Parse output
     if (!empty($contentFile) && file_exists(PATH_APP . $outputDir . DS . $contentFile)) {
         // Get compiled content mimetype
         $cType = Filesystem::mimetype(PATH_APP . $outputDir . DS . $contentFile);
         // Is image?
         if (strpos($cType, 'image/') !== false) {
             // Fix up object width & height
             list($width, $height, $type, $attr) = getimagesize(PATH_APP . $outputDir . DS . $contentFile);
             $xRatio = $view->oWidth / $width;
             $yRatio = $view->oHeight / $height;
             if ($xRatio * $height < $view->oHeight) {
                 // Resize the image based on width
                 $view->oHeight = ceil($xRatio * $height);
             } else {
                 // Resize the image based on height
                 $view->oWidth = ceil($yRatio * $width);
             }
         }
         // Download compiled file?
         if ($download) {
             $pdfName = $tex ? str_replace('temp__', '', basename($contentFile)) : basename($contentFile);
             // Serve up file
             $server = new \Hubzero\Content\Server();
             $server->filename(PATH_APP . $outputDir . DS . $contentFile);
             $server->disposition('attachment');
             $server->acceptranges(false);
             $server->saveas($pdfName);
             $result = $server->serve();
             if (!$result) {
                 // Should only get here on error
                 throw new Exception(Lang::txt('PLG_PROJECTS_FILES_SERVER_ERROR'), 404);
             } else {
                 exit;
             }
         }
         // Generate preview image for browsers that cannot embed pdf
         if ($cType == 'application/pdf') {
             // GS path
             $gspath = trim($this->params->get('gspath'), DS);
             if ($gspath && file_exists(DS . $gspath . DS . 'gs')) {
                 $gspath = DS . $gspath . DS;
                 $pdfName = $tex ? str_replace('temp__', '', basename($contentFile)) : basename($contentFile);
                 $pdfPath = PATH_APP . $outputDir . DS . $contentFile;
                 $exportPath = PATH_APP . $outputDir . DS . $tempBase . '%d.jpg';
                 exec($gspath . "gs -dNOPAUSE -sDEVICE=jpeg -r300 -dFirstPage=1 -dLastPage=1 -sOutputFile={$exportPath} {$pdfPath} 2>&1", $out);
                 if (is_file(PATH_APP . $outputDir . DS . $tempBase . '1.jpg')) {
                     $hi = new \Hubzero\Image\Processor(PATH_APP . $outputDir . DS . $tempBase . '1.jpg');
                     if (count($hi->getErrors()) == 0) {
                         $hi->resize($view->oWidth, false, false, true);
                         $hi->save(PATH_APP . $outputDir . DS . $tempBase . '1.jpg');
                     } else {
                         return false;
                     }
                 }
                 if (is_file(PATH_APP . $outputDir . DS . $tempBase . '1.jpg')) {
                     $image = $tempBase . '1.jpg';
                 }
             }
         }
     } elseif (!$this->getError()) {
         $this->setError(Lang::txt('PLG_PROJECTS_FILES_ERROR_COMPILE_PREVIEW_FAILED'));
     }
     $view->file = $file;
     $view->outputDir = $outputDir;
     $view->embed = $contentFile;
     $view->cType = $cType;
     $view->subdir = $this->subdir;
     $view->option = $this->_option;
     $view->image = !empty($image) ? $image : NULL;
     $view->model = $this->model;
     $view->repo = $this->repo;
     $view->connection = $this->connection;
     if ($this->getError()) {
         $view->setError($this->getError());
     }
     return $view->loadTemplate();
 }
Example #24
0
 /**
  * Process Registration
  *
  * @return     string
  */
 private function doRegister()
 {
     //get request vars
     $register = Request::getVar('register', NULL, 'post');
     $arrival = Request::getVar('arrival', NULL, 'post');
     $departure = Request::getVar('departure', NULL, 'post');
     $dietary = Request::getVar('dietary', NULL, 'post');
     $dinner = Request::getVar('dinner', NULL, 'post');
     $disability = Request::getVar('disability', NULL, 'post');
     $race = Request::getVar('race', NULL, 'post');
     $event_id = Request::getInt('event_id', NULL, 'post');
     //load event data
     $event = new \Components\Events\Models\Event($event_id);
     // get event params
     $params = new \Hubzero\Config\Registry($event->get('params'));
     //array to hold any errors
     $errors = array();
     //check for first name
     if (!isset($register['first_name']) || $register['first_name'] == '') {
         $errors[] = Lang::txt('Missing first name.');
     }
     //check for last name
     if (!isset($register['last_name']) || $register['last_name'] == '') {
         $errors[] = Lang::txt('Missing last name.');
     }
     //check for affiliation
     if (isset($register['affiliation']) && $register['affiliation'] == '') {
         $errors[] = Lang::txt('Missing affiliation.');
     }
     //check for email if email is supposed to be on
     if ($params->get('show_email', 1) == 1) {
         if (!isset($register['email']) || $register['email'] == '' || !filter_var($register['email'], FILTER_VALIDATE_EMAIL)) {
             $errors[] = Lang::txt('Missing email address or email is not valid.');
         }
         // check to make sure this is the only time registering
         if (\Components\Events\Tables\Respondent::checkUniqueEmailForEvent($register['email'], $event_id) > 0) {
             $errors[] = Lang::txt('You have previously registered for this event.');
         }
     }
     //if we have any errors we must return
     if (count($errors) > 0) {
         $this->register = $register;
         $this->arrival = $arrival;
         $this->departure = $departure;
         $this->dietary = $dietary;
         $this->dinner = $dinner;
         $this->disability = $disability;
         $this->race = $race;
         $this->setError(implode('<br />', $errors));
         return $this->register();
     }
     //set data for saving
     $eventsRespondent = new \Components\Events\Tables\Respondent(array());
     $eventsRespondent->event_id = $event_id;
     $eventsRespondent->registered = Date::toSql();
     $eventsRespondent->arrival = $arrival['day'] . ' ' . $arrival['time'];
     $eventsRespondent->departure = $departure['day'] . ' ' . $departure['time'];
     $eventsRespondent->position_description = '';
     if (isset($register['position_other']) && $register['position_other'] != '') {
         $eventsRespondent->position_description = $register['position_other'];
     } else {
         if (isset($register['position'])) {
             $eventsRespondent->position_description = $register['position'];
         }
     }
     $eventsRespondent->highest_degree = isset($register['degree']) ? $register['degree'] : '';
     $eventsRespondent->gender = isset($register['sex']) ? $register['sex'] : '';
     $eventsRespondent->disability_needs = isset($disability) && strtolower($disability) == 'yes' ? 1 : null;
     $eventsRespondent->dietary_needs = isset($dietary['needs']) && strtolower($dietary['needs']) == 'yes' ? $dietary['specific'] : null;
     $eventsRespondent->attending_dinner = isset($dinner) && $dinner == 'yes' ? 1 : 0;
     $eventsRespondent->bind($register);
     //did we save properly
     if (!$eventsRespondent->save($eventsRespondent)) {
         $this->setError($eventsRespondent->getError());
         return $this->register();
     }
     $r = $race;
     unset($r['nativetribe']);
     $r = empty($r) ? array() : $r;
     $sql = "INSERT INTO `#__events_respondent_race_rel` (respondent_id, race, tribal_affiliation)\n\t\t        VALUES (" . $this->database->quote($eventsRespondent->id) . ", " . $this->database->quote(implode(',', $r)) . ", " . $this->database->quote($race['nativetribe']) . ")";
     $this->database->setQuery($sql);
     $this->database->query();
     //load event we are registering for
     $eventsEvent = new \Components\Events\Tables\Event($this->database);
     $eventsEvent->load($event_id);
     // send a copy to event admin
     if ($eventsEvent->email != '') {
         //build message to send to event admin
         $email = new \Hubzero\Plugin\View(array('folder' => 'groups', 'element' => 'calendar', 'name' => 'calendar', 'layout' => 'register_email_admin'));
         $email->option = $this->option;
         $email->group = $this->group;
         $email->params = $params;
         $email->event = $eventsEvent;
         $email->sitename = Config::get('sitename');
         $email->register = $register;
         $email->race = $race;
         $email->dietary = $dietary;
         $email->disability = $disability;
         $email->arrival = $arrival;
         $email->departure = $departure;
         $email->dinner = $dinner;
         $message = str_replace("\n", "\r\n", $email->loadTemplate());
         //declare subject
         $subject = Lang::txt("[" . $email->sitename . "] Group \"{$this->group->get('description')}\" Event Registration: " . $eventsEvent->title);
         //make from array
         $from = array('email' => 'group-event-registration@' . $_SERVER['HTTP_HOST'], 'name' => $register['first_name'] . ' ' . $register['last_name']);
         // email from person
         if ($params->get('show_email', 1) == 1) {
             $from['email'] = $register['email'];
         }
         //send email
         $this->_sendEmail($eventsEvent->email, $from, $subject, $message);
     }
     // build message to send to event registerer
     // only send if show email is on
     if ($params->get('show_email', 1) == 1) {
         $email = $this->view('register_email_user', 'calendar');
         $email->option = $this->option;
         $email->group = $this->group;
         $email->params = $params;
         $email->event = $eventsEvent;
         $email->sitename = Config::get('sitename');
         $email->siteurl = Config::get('live_site');
         $email->register = $register;
         $email->race = $race;
         $email->dietary = $dietary;
         $email->disability = $disability;
         $email->arrival = $arrival;
         $email->departure = $departure;
         $email->dinner = $dinner;
         $message = str_replace("\n", "\r\n", $email->loadTemplate());
         // build to, from, & subject
         $to = User::get('email');
         $from = array('email' => 'groups@' . $_SERVER['HTTP_HOST'], 'name' => $email->sitename . ' Group Calendar: ' . $this->group->get('description'));
         $subject = Lang::txt('Thank you for Registering for the "%s" event', $eventsEvent->title);
         // send mail to user registering
         $this->_sendEmail($to, $from, $subject, $message);
     }
     // redirect back to the event
     App::redirect(Route::url('index.php?option=' . $this->option . '&cn=' . $this->group->get('cn') . '&active=calendar&action=details&event_id=' . $event_id), Lang::txt('You have successfully registered for the event.'), 'passed');
 }
Example #25
0
 /**
  * Build panel content
  *
  * @return  string  HTML
  */
 public function buildContent($pub = NULL, $viewname = 'edit')
 {
     $name = $viewname == 'freeze' || $viewname == 'curator' ? 'freeze' : 'draft';
     // Get selector styles
     \Hubzero\Document\Assets::addPluginStylesheet('projects', 'team', 'selector');
     // Output HTML
     $view = new \Hubzero\Plugin\View(array('folder' => 'projects', 'element' => 'publications', 'name' => $name, 'layout' => 'authors'));
     // Get authors
     if (!isset($pub->_authors)) {
         $pAuthors = new \Components\Publications\Tables\Author($this->_parent->_db);
         $pub->_authors = $pAuthors->getAuthors($pub->version_id);
         $pub->_submitter = $pAuthors->getSubmitter($pub->version_id, $pub->created_by);
     }
     // Get creator groups
     $view->groups = \Hubzero\User\Helper::getGroups($pub->_project->get('owned_by_user'), 'members', 1);
     $view->pub = $pub;
     $view->manifest = $this->_manifest;
     $view->step = $this->_blockId;
     // Get team members
     $objO = new \Components\Projects\Tables\Owner($this->_parent->_db);
     $view->teamids = $objO->getIds($pub->_project->get('id'), 'all', 0, 0);
     if ($this->getError()) {
         $view->setError($this->getError());
     }
     return $view->loadTemplate();
 }
Example #26
0
 /**
  * Include status bar - publication steps/sections/version navigation
  *
  * @return     array
  */
 public static function drawStatusBar($item, $step = NULL, $showSubSteps = false, $review = 0)
 {
     $view = new \Hubzero\Plugin\View(array('folder' => 'projects', 'element' => 'publications', 'name' => 'edit', 'layout' => 'statusbar'));
     $view->row = $item->row;
     $view->version = $item->version;
     $view->panels = $item->panels;
     $view->active = isset($item->active) ? $item->active : NULL;
     $view->move = isset($item->move) ? $item->move : 0;
     $view->step = $step;
     $view->lastpane = $item->lastpane;
     $view->option = $item->option;
     $view->project = $item->project;
     $view->current_idx = $item->current_idx;
     $view->last_idx = $item->last_idx;
     $view->checked = $item->checked;
     $view->url = $item->url;
     $view->review = $review;
     $view->show_substeps = $showSubSteps;
     $view->display();
 }
Example #27
0
 /**
  * Static method for formatting results
  *
  * @param      object $row Database row
  * @return     string HTML
  */
 public static function out($row)
 {
     include_once Component::path('com_forum') . DS . 'models' . DS . 'thread.php';
     $row->scope = $row->rcount;
     $row->scope_id = $row->data3;
     $row->section = $row->data2;
     $row->category = $row->data1;
     $p = explode(':', $row->params);
     $row->thread = $p[0];
     $row->parent = $p[1];
     $row->comment = $row->ftext;
     $view = new \Hubzero\Plugin\View(array('folder' => 'tags', 'element' => 'forum', 'name' => 'result'));
     $view->post = new \Components\Forum\Models\Post($row);
     return $view->loadTemplate();
 }
Example #28
0
 /**
  * Return data on a resource view (this will be some form of HTML)
  *
  * @param      object  $resource Current resource
  * @param      string  $option    Name of the component
  * @param      array   $areas     Active area(s)
  * @param      string  $rtrn      Data to be returned
  * @return     array
  */
 public function onResources($model, $option, $areas, $rtrn = 'all')
 {
     $arr = array('area' => $this->_name, 'html' => '', 'metadata' => '');
     // Check if our area is in the array of areas we want to return results for
     if (is_array($areas)) {
         if (!array_intersect($areas, $this->onResourcesAreas($model)) && !array_intersect($areas, array_keys($this->onResourcesAreas($model)))) {
             $rtrn = 'metadata';
         }
     }
     if (!$model->type->params->get('plg_citations')) {
         return $arr;
     }
     $database = App::get('db');
     // Get a needed library
     include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'tables' . DS . 'citation.php';
     include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'tables' . DS . 'association.php';
     include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'tables' . DS . 'author.php';
     include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'tables' . DS . 'secondary.php';
     // Get reviews for this resource
     $c = new \Components\Citations\Tables\Citation($database);
     $citations = $c->getCitations('resource', $model->resource->id);
     // Are we returning HTML?
     if ($rtrn == 'all' || $rtrn == 'html') {
         // Instantiate a view
         $view = new \Hubzero\Plugin\View(array('folder' => $this->_type, 'element' => $this->_name, 'name' => 'browse'));
         // Pass the view some info
         $view->option = $option;
         $view->resource = $model->resource;
         $view->citations = $citations;
         $view->citationFormat = $this->params->get('format', 'APA');
         if ($this->getError()) {
             $view->setError($this->getError());
         }
         // Return the output
         $arr['html'] = $view->loadTemplate();
     }
     // Are we returning metadata?
     if ($rtrn == 'all' || $rtrn == 'metadata') {
         $view = new \Hubzero\Plugin\View(array('folder' => $this->_type, 'element' => $this->_name, 'name' => 'metadata'));
         $view->url = Route::url('index.php?option=' . $option . '&' . ($model->resource->alias ? 'alias=' . $model->resource->alias : 'id=' . $model->resource->id) . '&active=citations');
         $view->citations = $citations;
         $arr['metadata'] = $view->loadTemplate();
     }
     // Return results
     return $arr;
 }
Example #29
0
 /**
  * Save a review
  *
  * @return  void
  */
 public function savereview()
 {
     // Is the user logged in?
     if (User::isGuest()) {
         $this->setError(Lang::txt('PLG_PUBLICATIONS_REVIEWS_LOGIN_NOTICE'));
         return;
     }
     $publication =& $this->publication;
     // Do we have a publication ID?
     if (!$publication->exists()) {
         // No ID - fail! Can't do anything else without an ID
         $this->setError(Lang::txt('PLG_PUBLICATIONS_REVIEWS_NO_RESOURCE_ID'));
         return;
     }
     $database = App::get('db');
     // Bind the form data to our object
     $row = new \Components\Publications\Tables\Review($database);
     if (!$row->bind($_POST)) {
         $this->setError($row->getError());
         return;
     }
     // Perform some text cleaning, etc.
     $row->id = Request::getInt('reviewid', 0);
     $row->state = 1;
     $row->comment = \Hubzero\Utility\Sanitize::stripAll($row->comment);
     $row->anonymous = $row->anonymous == 1 || $row->anonymous == '1' ? $row->anonymous : 0;
     $row->created = $row->created ? $row->created : Date::toSql();
     $row->created_by = User::get('id');
     $message = $row->id ? Lang::txt('PLG_PUBLICATIONS_REVIEWS_EDITS_SAVED') : Lang::txt('PLG_PUBLICATIONS_REVIEWS_REVIEW_POSTED');
     // Check for missing (required) fields
     if (!$row->check()) {
         $this->setError($row->getError());
         return;
     }
     // Save the data
     if (!$row->store()) {
         $this->setError($row->getError());
         return;
     }
     // Calculate the new average rating for the parent publication
     $publication->table()->calculateRating();
     $publication->table()->updateRating();
     // Process tags
     $tags = trim(Request::getVar('review_tags', ''));
     if ($tags) {
         $rt = new \Components\Publications\Helpers\Tags($database);
         $rt->tag_object($row->created_by, $publication->get('id'), $tags, 1, 0);
     }
     // Get version authors
     $users = $publication->table('Author')->getAuthors($publication->get('version_id'), 1, 1, true);
     // Build the subject
     $subject = Config::get('sitename') . ' ' . Lang::txt('PLG_PUBLICATIONS_REVIEWS_CONTRIBUTIONS');
     // Message
     $eview = new \Hubzero\Plugin\View(array('folder' => 'publications', 'element' => 'reviews', 'name' => 'emails'));
     $eview->option = $this->_option;
     $eview->juser = User::getInstance();
     $eview->publication = $publication;
     $message = $eview->loadTemplate();
     $message = str_replace("\n", "\r\n", $message);
     // Build the "from" data for the e-mail
     $from = array();
     $from['name'] = Config::get('sitename') . ' ' . Lang::txt('PLG_PUBLICATIONS_REVIEWS_CONTRIBUTIONS');
     $from['email'] = Config::get('mailfrom');
     // Send message
     if (!Event::trigger('xmessage.onSendMessage', array('publications_new_comment', $subject, $message, $from, $users, $this->_option))) {
         $this->setError(Lang::txt('PLG_PUBLICATIONS_REVIEWS_FAILED_TO_MESSAGE'));
     }
     App::redirect(Route::url($publication->link('reviews')), $message);
     return;
 }
Example #30
0
 /**
  * Get File Previews
  *
  * @param   string  $ref  Reference to files
  * @return  mixed
  */
 protected function _getFilesPreview($ref = '')
 {
     if (!$ref) {
         return false;
     }
     if (!$this->_path) {
         // Get project file path
         $this->_path = \Components\Projects\Helpers\Html::getProjectRepoPath($this->model->get('alias'));
     }
     // We do need project file path
     if (!$this->_path || !is_dir($this->_path)) {
         return false;
     }
     $files = explode(',', $ref);
     $selected = array();
     $maxHeight = 0;
     $minHeight = 0;
     $minWidth = 0;
     $maxWidth = 0;
     $imagepath = trim($this->_config->get('imagepath', '/site/projects'), DS);
     $to_path = DS . $imagepath . DS . strtolower($this->model->get('alias')) . DS . 'preview';
     foreach ($files as $item) {
         $parts = explode(':', $item);
         $file = count($parts) > 1 ? $parts[1] : $parts[0];
         $hash = count($parts) > 1 ? $parts[0] : NULL;
         if ($hash) {
             // Only preview mid-size images from now on
             $hashed = md5(basename($file) . '-' . $hash) . '.png';
             if (is_file(PATH_APP . $to_path . DS . $hashed)) {
                 $preview['image'] = $hashed;
                 $preview['url'] = NULL;
                 $preview['title'] = basename($file);
                 // Get image properties
                 list($width, $height, $type, $attr) = getimagesize(PATH_APP . $to_path . DS . $hashed);
                 $preview['width'] = $width;
                 $preview['height'] = $height;
                 $preview['orientation'] = $width > $height ? 'horizontal' : 'vertical';
                 // Record min and max width and height to build image grid
                 if ($height >= $maxHeight) {
                     $maxHeight = $height;
                 }
                 if ($height && $height <= $minHeight) {
                     $minHeight = $height;
                 } else {
                     $minHeight = $height;
                 }
                 if ($width > $maxWidth) {
                     $maxWidth = $width;
                 }
                 $selected[] = $preview;
             }
         }
     }
     // No files for preview
     if (empty($selected)) {
         return false;
     }
     // Output HTML
     $view = new \Hubzero\Plugin\View(array('folder' => 'projects', 'element' => $this->_name, 'name' => 'preview', 'layout' => 'files'));
     $view->maxHeight = $maxHeight;
     $view->maxWidth = $maxWidth;
     $view->minHeight = $minHeight > 400 ? 400 : $minHeight;
     $view->selected = $selected;
     $view->option = $this->_option;
     $view->model = $this->model;
     return $view->loadTemplate();
 }