Пример #1
0
 /**
  * Initiate the editor. Push scripts to document if needed
  *
  * @return     string
  */
 public function onInit()
 {
     if ($this->_pushscripts) {
         \Hubzero\Document\Assets::addPluginStylesheet('editors', $this->_name);
         \Hubzero\Document\Assets::addPluginScript('editors', $this->_name);
         $this->_pushscripts = false;
     }
     return '';
 }
Пример #2
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();
 }
Пример #3
0
 public static function onRenderOption($return, $title = 'With an affiliated institution:')
 {
     // hide the login box if the plugin is in "debug mode" and the special key is not set in the request
     $params = Plugin::params('authentication', 'shibboleth');
     if (($testKey = $params->get('testkey', NULL)) && !array_key_exists($testKey, $_GET)) {
         return '<span />';
     }
     // saved id provider? use it as the default
     $prefill = isset($_COOKIE['shib-entity-id']) ? $_COOKIE['shib-entity-id'] : NULL;
     if (!$prefill && ($host = self::getHostByAddress(isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'], $params->get('dns', '8.8.8.8'))) && preg_match('/[.]([^.]*?[.][a-z0-9]+?)$/', $host, $ma)) {
         // hostname lookup seems php jsonrational (not an ip address, has a few dots in it
         // try to look up a provider to pre-select based on the user's hostname
         foreach (self::getInstitutions() as $inst) {
             if (fnmatch('*' . $ma[1], $inst['host'])) {
                 $prefill = $inst['entity_id'];
                 break;
             }
         }
     }
     // attach style and scripts
     foreach (array('bootstrap.min.js', 'bootstrap-select.min.js', 'shibboleth.js', 'bootstrap.min.css', 'bootstrap-select.min.css', 'bootstrap-theme.min.css', 'shibboleth.css') as $asset) {
         $isJs = preg_match('/[.]js$/', $asset);
         if ($isJs) {
             \Hubzero\Document\Assets::addPluginScript('authentication', 'shibboleth', $asset);
         } else {
             \Hubzero\Document\Assets::addPluginStylesheet('authentication', 'shibboleth', $asset);
         }
     }
     list($a, $h) = self::htmlify();
     // make a dropdown/button combo that (hopefully) gets prettied up client-side into a bootstrap dropdown
     $html = array();
     $html[] = '<form class="shibboleth account incommon-color" action="' . Route::url('index.php?option=com_users&view=login') . '" method="get">';
     $html[] = '<div class="default-icon"></div>';
     $html[] = '<select title="' . $a($title) . '" name="idp">';
     $html[] = '<option class="placeholder">' . $h($title) . '</option>';
     foreach (self::getInstitutions() as $idp) {
         $logo = isset($idp['logo_data']) && $idp['logo_data'] ? '<img src="' . $idp['logo_data'] . '" />' : '<span class="logo-placeholder"></span>';
         $html[] = '<option ' . ($prefill == $idp['entity_id'] ? 'selected="selected" ' : '') . 'value="' . $a($idp['entity_id']) . '" data-content="' . $a($logo . ' ' . $h($idp['label'])) . '">' . $h($idp['label']) . '</option>';
     }
     $html[] = '</select>';
     $html[] = '<input type="hidden" name="authenticator" value="shibboleth" />';
     if ($return) {
         $html[] = '<input type="hidden" name="return" value="' . $a(preg_replace('/^.return=/', '', $return)) . '" />';
     }
     $html[] = '<button class="submit" type="submit">Sign in</button>';
     $html[] = '</form>';
     return $html;
 }
Пример #4
0
 /**
  * Edit project info
  *
  * @return     void
  */
 public function editTask()
 {
     // Incoming project ID
     $id = Request::getVar('id', array(0));
     if (is_array($id)) {
         $id = $id[0];
     }
     // Push some styles to the template
     \Hubzero\Document\Assets::addPluginStylesheet('projects', 'files', 'diskspace.css');
     \Hubzero\Document\Assets::addPluginScript('projects', 'files', 'diskspace.js');
     \Hubzero\Document\Assets::addPluginScript('projects', 'files');
     $this->view = $this->view;
     $this->view->config = $this->config;
     $model = new Models\Project($id);
     $objAC = $model->table('Activity');
     if ($id) {
         if (!$model->exists()) {
             App::redirect(Route::url('index.php?option=' . $this->_option, false), Lang::txt('COM_PROJECTS_NOTICE_ID_NOT_FOUND'), 'error');
             return;
         }
     }
     if (!$id) {
         App::redirect(Route::url('index.php?option=' . $this->_option, false), Lang::txt('COM_PROJECTS_NOTICE_NEW_PROJECT_FRONT_END'), 'error');
         return;
     }
     // Get project types
     $objT = $model->table('Type');
     $this->view->types = $objT->getTypes();
     // Get activity counts
     $counts = Event::trigger('projects.onProjectCount', array($model, 1));
     $counts = Helpers\Html::getCountArray($counts);
     $counts['activity'] = $objAC->getActivityCount($model->get('id'), User::get('id'));
     $this->view->counts = $counts;
     // Get team
     $objO = $model->table('Owner');
     // Sync with system group
     $objO->sysGroup($model->get('alias'), $this->config->get('group_prefix', 'pr-'));
     // Get members and managers
     $this->view->managers = $objO->getOwnerNames($id, 0, '1', 1);
     $this->view->members = $objO->getOwnerNames($id, 0, '0', 1);
     $this->view->authors = $objO->getOwnerNames($id, 0, '2', 1);
     $this->view->reviewers = $objO->getOwnerNames($id, 0, '5', 1);
     // Get last activity
     $afilters = array('limit' => 1);
     $last_activity = $objAC->getActivities($id, $afilters);
     $this->view->last_activity = count($last_activity) > 0 ? $last_activity[0] : '';
     // Was project suspended?
     $this->view->suspended = false;
     $setup_complete = $this->config->get('confirm_step', 0) ? 3 : 2;
     if ($model->isInactive()) {
         $this->view->suspended = $objAC->checkActivity($id, Lang::txt('COM_PROJECTS_ACTIVITY_PROJECT_SUSPENDED'));
     }
     // Get project params
     $this->view->params = $model->params;
     $content = Event::trigger('projects.diskspace', array($model, 'local', 'admin'));
     $this->view->diskusage = isset($content[0]) ? $content[0] : '';
     // Set any errors
     if ($this->getError()) {
         $this->view->setError($this->getError());
     }
     // Get tags on this item
     $cloud = new Models\Tags($id);
     $this->view->tags = $cloud->render('string');
     // Output the HTML
     $this->view->model = $model;
     $this->view->publishing = $this->_publishing;
     $this->view->display();
 }
Пример #5
0
<?php

// no direct access
defined('_HZEXEC_') or die;
$this->css()->css('jquery.fancybox.css', 'system')->js();
// Add projects stylesheet
\Hubzero\Document\Assets::addComponentStylesheet('com_projects');
\Hubzero\Document\Assets::addComponentScript('com_projects');
\Hubzero\Document\Assets::addPluginStylesheet('projects', 'files', 'uploader');
\Hubzero\Document\Assets::addPluginScript('projects', 'files', 'jquery.fileuploader.js');
\Hubzero\Document\Assets::addPluginScript('projects', 'files', 'jquery.queueuploader.js');
?>
<header id="content-header">
	<h2><?php 
echo $this->title;
?>
</h2>
</header><!-- / #content-header -->

<?php 
if ($this->pid && !empty($this->project) && $this->project->get('created_by_user') == User::get('id')) {
    ?>
	<p class="contrib-options">
		<?php 
    echo Lang::txt('PLG_PROJECTS_PUBLICATIONS_NEED_A_PROJECT');
    ?>
		<a href="<?php 
    echo Route::url('index.php?option=com_projects&alias=' . $this->project->get('alias') . '&action=activate');
    ?>
">
		<?php 
Пример #6
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 (!is_null($enabled = $model->type->params->get('plg_classrooms')) && !$enabled) {
            return $arr;
        }
        // Are we returning HTML?
        if ($rtrn == 'all' || $rtrn == 'html') {
            $arr['html'] = array('<div id="no-usage"><p class="warning">' . Lang::txt('PLG_RESOURCES_CLASSROOMS_NO_DATA_FOUND') . '</p></div>');
            if (self::any($model->resource->alias)) {
                \Hubzero\Document\Assets::addPluginStyleSheet($this->_type, $this->_name);
                \Hubzero\Document\Assets::addPluginScript($this->_type, $this->_name);
                \Hubzero\Document\Assets::addSystemScript('d3.v2.js');
                $dbh = App::get('db');
                $tool = $dbh->quote($model->resource->alias);
                $dbh->setQuery('SELECT DISTINCT
					c2.toolname AS tool,
					c2.clustersize AS size,
					YEAR(c2.cluster_start) AS year,
					c2.cluster_start,
					c2.cluster_end,
					c2.first_use,
					SUBSTRING_INDEX(c2.cluster, \'|\', 1) AS semester,
					CONCAT(SUBSTRING_INDEX(c2.cluster, \'|\', 1), \'|\', SUBSTRING_INDEX(c2.cluster, \'|\', -2)) AS cluster,
					SHA1(CONCAT(c2.uidNumber, ' . $dbh->quote(uniqid()) . ')) AS uid
					FROM
					(SELECT DISTINCT cluster FROM #__resource_stats_clusters WHERE toolname = ' . $tool . ') AS ct,
					#__resource_stats_clusters AS c2
					WHERE ct.cluster = c2.cluster');
                $nodes = array();
                foreach ($dbh->loadAssocList() as $row) {
                    if (!isset($nodes[$row['semester']])) {
                        $nodes[$row['semester']] = array();
                    }
                    foreach (array('cluster_start', 'cluster_end', 'first_use') as $dateCol) {
                        $row[$dateCol] = date('r', strtotime($row[$dateCol]));
                    }
                    $nodes[$row['semester']][] = $row;
                }
                $arr['html'][] = '<span id="cluster-data" data-tool="' . str_replace('"', '&quot;', $model->resource->alias) . '" data-seed="' . str_replace('"', '&quot;', json_encode(array_values($nodes))) . '"></span>';
            }
            $arr['html'] = implode("\n", $arr['html']);
        }
        return $arr;
    }
Пример #7
0
}
if (!$isRegister) {
    // Instantiate a new profile object
    $profile = \Hubzero\User\Profile::getInstance(User::get('id'));
    if ($profile) {
        $fname = $fname ?: $profile->get('givenName');
        $lname = $lname ?: $profile->get('surname');
        $email = $email ?: $profile->get('email');
    }
}
$returnOrcid = Request::getInt('return', 0);
$isRegister = $returnOrcid == 1;
if (Request::getInt('return', 0) == 1) {
    $this->js('register.js');
} else {
    \Hubzero\Document\Assets::addPluginScript('members', 'profile');
}
$this->css('orcid.css');
$srv = $this->config->get('orcid_service', 'members');
$tkn = $this->config->get('orcid_' . $srv . '_token');
?>
<section class="main section">
	<form name="orcid-search-form">
		<?php 
if ($srv != 'public' && !$tkn) {
    ?>
			<p class="warning"><?php 
    echo Lang::txt('This service is currently unavailable and/or not configured correctly. Please contact <a href="%s">support</a> for further assistance.', Route::url('index.php?option=com_support'));
    ?>
</p>
		<?php