/** * 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) { if (!$offering->access('manage', 'section')) { return; } $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', 'managers'))->set('display_menu_tab', true)->set('icon', 'f083'); if ($describe) { return $response; } $nonadmin = Request::getState('com_courses.offering' . $offering->get('id') . '.nonadmin', 0); if (!($active = Request::getVar('active')) && !$nonadmin) { Request::setVar('active', $active = $this->_name); } if ($response->get('name') == $active) { // Set the page title Document::setTitle(Document::getTitle() . ': ' . Lang::txt('PLG_COURSES_' . strtoupper($this->_name))); Pathway::append(Lang::txt('PLG_COURSES_' . strtoupper($this->_name)), $offering->link() . '&active=' . $this->_name); $view = with($this->view('default', 'overview'))->set('option', Request::getVar('option', 'com_courses'))->set('course', $course)->set('offering', $offering)->set('params', $this->params); foreach ($this->getErrors() as $error) { $view->setError($error); } $response->set('html', $view->loadTemplate()); } // Return the output return $response; }
/** * Tests the Filter format access permissions functionality. */ function testFormatPermissions() { // Make sure that a regular user only has access to the text formats for // which they were granted access. $fallback_format = entity_load('filter_format', filter_fallback_format()); $this->assertTrue($this->allowed_format->access('use', $this->web_user), 'A regular user has access to use a text format they were granted access to.'); $this->assertEqual(AccessResult::allowed()->cachePerRole(), $this->allowed_format->access('use', $this->web_user, TRUE), 'A regular user has access to use a text format they were granted access to.'); $this->assertFalse($this->disallowed_format->access('use', $this->web_user), 'A regular user does not have access to use a text format they were not granted access to.'); $this->assertEqual(AccessResult::neutral(), $this->disallowed_format->access('use', $this->web_user, TRUE)); //, 'A regular user does not have access to use a text format they were not granted access to.'); $this->assertTrue($fallback_format->access('use', $this->web_user), 'A regular user has access to use the fallback format.'); $this->assertEqual(AccessResult::allowed(), $fallback_format->access('use', $this->web_user, TRUE), 'A regular user has access to use the fallback format.'); // Perform similar checks as above, but now against the entire list of // available formats for this user. $this->assertTrue(in_array($this->allowed_format->format, array_keys(filter_formats($this->web_user))), 'The allowed format appears in the list of available formats for a regular user.'); $this->assertFalse(in_array($this->disallowed_format->format, array_keys(filter_formats($this->web_user))), 'The disallowed format does not appear in the list of available formats for a regular user.'); $this->assertTrue(in_array(filter_fallback_format(), array_keys(filter_formats($this->web_user))), 'The fallback format appears in the list of available formats for a regular user.'); // Make sure that a regular user only has permission to use the format // they were granted access to. $this->assertTrue($this->web_user->hasPermission($this->allowed_format->getPermissionName()), 'A regular user has permission to use the allowed text format.'); $this->assertFalse($this->web_user->hasPermission($this->disallowed_format->getPermissionName()), 'A regular user does not have permission to use the disallowed text format.'); // Make sure that the allowed format appears on the node form and that // the disallowed format does not. $this->drupalLogin($this->web_user); $this->drupalGet('node/add/page'); $elements = $this->xpath('//select[@name=:name]/option', array(':name' => 'body[0][format]', ':option' => $this->allowed_format->format)); $options = array(); foreach ($elements as $element) { $options[(string) $element['value']] = $element; } $this->assertTrue(isset($options[$this->allowed_format->format]), 'The allowed text format appears as an option when adding a new node.'); $this->assertFalse(isset($options[$this->disallowed_format->format]), 'The disallowed text format does not appear as an option when adding a new node.'); $this->assertFalse(isset($options[filter_fallback_format()]), 'The fallback format does not appear as an option when adding a new node.'); // Check regular user access to the filter tips pages. $this->drupalGet('filter/tips/' . $this->allowed_format->format); $this->assertResponse(200); $this->drupalGet('filter/tips/' . $this->disallowed_format->format); $this->assertResponse(403); $this->drupalGet('filter/tips/' . filter_fallback_format()); $this->assertResponse(200); $this->drupalGet('filter/tips/invalid-format'); $this->assertResponse(404); // Check admin user access to the filter tips pages. $this->drupalLogin($this->admin_user); $this->drupalGet('filter/tips/' . $this->allowed_format->format); $this->assertResponse(200); $this->drupalGet('filter/tips/' . $this->disallowed_format->format); $this->assertResponse(200); $this->drupalGet('filter/tips/' . filter_fallback_format()); $this->assertResponse(200); $this->drupalGet('filter/tips/invalid-format'); $this->assertResponse(404); }
/** * Event call to return data for a specific project * * @param object $model Project model * @param string $action Plugin task * @param string $areas Plugins to return data * @return array Return array of html */ public function onProject($model, $action = '', $areas = NULL) { $returnhtml = true; $arr = array('html' => '', 'metadata' => ''); // Get this area details $this->_area = $this->onProjectAreas(); // Check if our area is in the array of areas we want to return results for if (is_array($areas)) { if (empty($this->_area) || !in_array($this->_area['name'], $areas)) { return; } } // Check that project exists if (!$model->exists()) { return $arr; } // Check authorization if (!$model->access('member')) { return $arr; } // Are we returning HTML? if ($returnhtml) { $fields = Components\Projects\Models\Orm\Description\Field::all()->order('ordering', 'ASC')->rows(); $projectDescription = Components\Projects\Models\Orm\Description::all()->where('project_id', '=', $model->get('id'))->rows(); $info = array(); foreach ($fields as $field) { foreach ($projectDescription as $description) { if ($description->description_key == $field->name) { $f = new stdClass(); $f->label = $field->label; $f->value = $description->description_value; array_push($info, $f); } } } // Set vars $view = $this->view('default', 'view')->set('option', 'com_projects')->set('info', $info)->set('model', $model); $arr['html'] = $view->loadTemplate(); } // Return data return $arr; }
/** * This function is used by different methods in controller to restrict * user access by checking the passed object and object id * * @param string $permission permisson passed by function * @param object $obj An object of a model * @param int $obj_id object id of model ie primary key * * @return object */ protected function access($permission, $obj = null, $obj_id = 0) { $response = null; if ($obj_id) { $response = $obj->find($obj_id); if (!$response) { App::abort(404, Lang::get('messages.errors.corporate.missing')); } } if (!(Auth::check() && Auth::user()->can($permission))) { App::abort(403, Lang::get('messages.errors.corporate.access', array('section' => 'requested'))); } if ($response) { if (!(Auth::user()->is('CRM User') || Auth::user()->is_super || Auth::user()->is('Loylty Admin'))) { if (!$obj->access($obj_id, Auth::user()->corporate_id)) { App::abort(403, Lang::get('messages.errors.corporate.access', array('section' => 'requested'))); } } } return $response; }
/** * Event call to get side content * * @param object $model * @param string $area * @return mixed */ public function onProjectExtras($model, $area) { // Check if our area is the one we want to return results for if ($area != 'feed') { return; } // No suggestions for read-only users if (!$model->access('content')) { return false; } // Allow to place custom modules on project pages $html = \Hubzero\Module\Helper::renderModules('projectpage'); // Side blocks from other plugins? $sections = Event::trigger('projects.onProjectMiniList', array($model)); if (!empty($sections)) { // Show subscription to feed (new) $subscribe = Event::trigger('projects.onProjectMember', array($model)); $html .= !empty($subscribe[0]) ? $subscribe[0] : NULL; foreach ($sections as $section) { $html .= !empty($section) ? $section : NULL; } } return $html; }
/** * Event call to return data for a specific project * * @param object $model Project model * @param string $action Plugin task * @param string $areas Plugins to return data * @return array Return array of html */ public function onProject($model, $action = '', $areas = null) { $returnhtml = true; $arr = array('html' => '', 'metadata' => ''); // Get this area details $this->_area = $this->onProjectAreas(); // Check if our area is in the array of areas we want to return results for if (is_array($areas)) { if (empty($this->_area) || !in_array($this->_area['name'], $areas)) { return; } } // Check that project exists if (!$model->exists()) { return $arr; } // Check authorization if (!$model->access('member')) { return $arr; } // Model $this->model = $model; // Are we returning HTML? if ($returnhtml) { // Get our To do model $this->todo = new \Components\Projects\Models\Todo(); // Set vars $this->_task = $action ? $action : Request::getVar('action', ''); $this->_todoid = Request::getInt('todoid', 0); $this->_database = App::get('db'); $this->_uid = User::get('id'); switch ($this->_task) { case 'page': default: $arr['html'] = $this->page(); break; case 'save': $arr['html'] = $this->save(); break; case 'changestate': $arr['html'] = $this->save(); break; case 'delete': $arr['html'] = $this->delete(); break; case 'assign': $arr['html'] = $this->save(); break; case 'view': case 'new': case 'edit': $arr['html'] = $this->item(); break; case 'savecomment': $arr['html'] = $this->_saveComment(); break; case 'deletecomment': $arr['html'] = $this->_deleteComment(); break; case 'reorder': case 'sortitems': $arr['html'] = $this->reorder(); break; } } // Return data return $arr; }
/** * Event call to return data for a specific project * * @param object $model Project model * @param string $action Plugin task * @param string $areas Plugins to return data * @return array Return array of html */ public function onProject($model, $action = 'view', $areas = null) { $arr = array('html' => '', 'metadata' => '', 'message' => '', 'error' => ''); // Get this area details $this->_area = $this->onProjectAreas(); // Check if our area is in the array of areas we want to return results for if (is_array($areas)) { if (empty($this->_area) || !in_array($this->_area['name'], $areas)) { return; } } // Check authorization if ($model->exists() && !$model->access('member')) { return $arr; } // Model $this->model = $model; // Load component configs $this->_config = $model->config(); $this->gitpath = $this->_config->get('gitpath', '/opt/local/bin/git'); // Incoming $raw_op = Request::getInt('raw_op', 0); $action = $action ? $action : Request::getVar('action', 'list'); // Get this area details $this->_area = $this->onProjectAreas(); // Check if our area is in the array of areas we want to return results for if (is_array($areas)) { if (empty($this->_area) || !in_array($this->_area['name'], $areas)) { return $arr; } } $this->_database = App::get('db'); $this->_uid = User::get('id'); // Publishing? if ($action == 'browser') { return $this->browser(); } if ($action == 'select') { return $this->select(); } $act_func = 'act_' . $action; if (!method_exists($this, $act_func)) { if ($raw_op) { print json_encode(array('status' => 'success', 'data' => $table)); exit; } else { $act_func = 'act_list'; } } // detect CR as new line ini_set('auto_detect_line_endings', true); if ($raw_op) { $this->{$act_func}(); exit; } else { Document::addScript('//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'); Document::addScript('//ajax.googleapis.com/ajax/libs/jqueryui/1.8.24/jquery-ui.min.js'); Document::addStyleSheet('//ajax.googleapis.com/ajax/libs/jqueryui/1.8.24/themes/smoothness/jquery-ui.css'); Document::addScript('/core/plugins/projects/databases/res/main.js'); Document::addStyleSheet('/core/plugins/projects/databases/res/main.css'); if (file_exists(__DIR__ . '/res/ds.' . $action . '.js')) { Document::addScript('/core/plugins/projects/databases/res/ds.' . $action . '.js'); } if (file_exists(__DIR__ . '/res/ds.' . $action . '.css')) { Document::addStyleSheet('/core/plugins/projects/databases/res/ds.' . $action . '.css'); } return $this->{$act_func}(); } }
/** * Event call to return data for a specific project * * @param object $model Project model * @param string $action Plugin task * @param string $areas Plugins to return data * @return array Return array of html */ public function onProject($model, $action = '', $areas = null) { $returnhtml = true; $arr = array('html' => '', 'metadata' => '', 'message' => '', 'error' => ''); // Get this area details $this->_area = $this->onProjectAreas(); // Check if our area is in the array of areas we want to return results for if (is_array($areas)) { if (empty($this->_area) || !in_array($this->_area['name'], $areas)) { return; } } // Check authorization if ($model->exists() && !$model->access('member')) { return $arr; } // Model $this->model = $model; // Incoming $this->_task = Request::getVar('action', ''); $this->_pid = Request::getInt('pid', 0); if (!$this->_task) { $this->_task = $this->_pid ? 'publication' : $action; } $this->_uid = User::get('id'); $this->_database = App::get('db'); $this->_config = $this->model->config(); $this->_pubconfig = Component::params('com_publications'); // Common extensions (for gallery) $this->_image_ext = \Components\Projects\Helpers\Html::getParamArray($this->params->get('image_types', 'bmp, jpeg, jpg, png')); $this->_video_ext = \Components\Projects\Helpers\Html::getParamArray($this->params->get('video_types', 'avi, mpeg, mov, wmv')); // Check if exists or new if (!$this->model->exists()) { // Contribute process outside of projects $this->model->set('provisioned', 1); $ajax_tasks = array('showoptions', 'save', 'showitem'); $this->_task = $action == 'start' ? 'start' : 'contribute'; if ($action == 'publication') { $this->_task = 'publication'; } elseif (in_array($action, $ajax_tasks)) { $this->_task = $action; } } elseif ($this->model->isProvisioned()) { // No browsing within provisioned project $this->_task = $action == 'browse' ? 'contribute' : $action; } \Hubzero\Document\Assets::addPluginStylesheet('projects', 'publications'); \Hubzero\Document\Assets::addPluginStylesheet('projects', 'publications', 'curation'); \Hubzero\Document\Assets::addPluginScript('projects', 'publications', 'curation'); // Actions switch ($this->_task) { case 'browse': default: $arr['html'] = $this->browse(); break; case 'start': case 'new': $arr['html'] = $this->startDraft(); break; case 'edit': case 'publication': case 'continue': case 'review': $arr['html'] = $this->editDraft(); break; case 'newversion': case 'savenew': $arr['html'] = $this->newVersion(); break; case 'checkstatus': $arr['html'] = $this->checkStatus(); break; case 'select': $arr['html'] = $this->select(); break; case 'saveparam': $arr['html'] = $this->saveParam(); break; // Change publication state // Change publication state case 'publish': case 'republish': case 'archive': case 'revert': case 'post': $arr['html'] = $this->publishDraft(); break; case 'apply': case 'save': case 'rewind': case 'reorder': case 'deleteitem': case 'additem': case 'dispute': case 'skip': case 'undispute': case 'saveitem': $arr['html'] = $this->saveDraft(); break; // Individual items editing // Individual items editing case 'edititem': case 'editauthor': $arr['html'] = $this->editItem(); break; case 'suggest_license': case 'save_license': $arr['html'] = $this->_suggestLicense(); break; // Show all publication versions // Show all publication versions case 'versions': $arr['html'] = $this->versions(); break; // Unpublish/delete // Unpublish/delete case 'cancel': $arr['html'] = $this->cancelDraft(); break; // Contribute process outside of projects // Contribute process outside of projects case 'contribute': $arr['html'] = $this->contribute(); break; // Show stats // Show stats case 'stats': $arr['html'] = $this->_stats(); break; case 'diskspace': $arr['html'] = $this->pubDiskSpace($this->model); break; // Handlers // Handlers case 'handler': $arr['html'] = $this->handler(); break; } // Return data return $arr; }
/** * Check a user's authorization * * @param string $action Action to check * @return boolean True if authorized, false if not */ public function access($action = 'view', $item = 'course') { return $this->_permissions->access($action, $item); }
/** * Return data on a project team member * * @param object $project Current publication * @return array */ public function onProjectMember($project) { // Only show for logged-in users if (User::isGuest()) { return false; } // Only show to members if (!$project->access('member')) { return false; } $this->database = App::get('db'); $this->project = $project; // Item watch class $this->watch = new \Hubzero\Item\Watch($this->database); $this->action = strtolower(Request::getWord('action', '')); switch ($this->action) { case 'save': return $this->_save(); break; case 'manage': return array('html' => $this->_manage()); break; default: return $this->_status(); break; } }
/** * Event call to return data for a specific project * * @param object $model Project model * @param string $action Plugin task * @param string $areas Plugins to return data * @return array Return array of html */ public function onProject($model, $action = '', $areas = null) { $returnhtml = true; $arr = array('html' => '', 'metadata' => ''); // Get this area details $this->_area = $this->onProjectAreas(); // Check if our area is in the array of areas we want to return results for if (is_array($areas)) { if (empty($this->_area) || !in_array($this->_area['name'], $areas)) { return; } } // Check that project exists if (!$model->exists()) { return $arr; } // Check authorization if (!$model->access('member')) { return $arr; } // Model $this->model = $model; // Are we returning HTML? if ($returnhtml) { // Set vars $this->_task = $action ? $action : Request::getVar('action', ''); $this->_database = App::get('db'); $this->_uid = User::get('id'); $this->_config = $model->config(); switch ($this->_task) { case 'edit': case 'setup': $arr['html'] = $this->display(1); break; case 'delete': case 'deleteit': $arr['html'] = $this->delete(); break; case 'changerole': case 'assignrole': $arr['html'] = $this->_changeRole(); break; case 'changeowner': $arr['html'] = $this->_changeOwner(); break; case 'save': $arr['html'] = $this->_save(); break; case 'quit': $arr['html'] = $this->_quit(); break; case 'view': default: $arr['html'] = $this->display(); break; case 'select': case 'newauthor': $arr['html'] = $this->select(); break; } } // Return data return $arr; }
/** * Check a user's authorization * * @param string $action Action to check * @return boolean True if authorized, false if not */ public function access($action = 'view', $item = 'offering') { if (!isset($this->_permissions)) { $this->_permissions = Permissions::getInstance(); $this->_permissions->set('course_id', $this->get('course_id')); $this->_permissions->set('offering_id', $this->get('id')); $this->_permissions->set('section_id', $this->section()->get('id')); } return $this->_permissions->access($action, $item); }
/** * Overrides the $node->access() and $account->hasPermission() permission to * access and edit webform components, e-mails, conditions, and form settings. * * Return NULL to defer to other modules. If all implementations defer, then * access to the node's EDIT tab plus 'edit webform components' permission * determines access. To grant access, return TRUE; to deny access, return * FALSE. If more than one implementation return TRUE/FALSE, all must be TRUE * to grant access. * * In this way, access to the EDIT tab of the node may be decoupled from * access to the WEBFORM tab. When returning TRUE, consider all aspects of * access as this will be the only test. For example, 'return TRUE;' would grant * annonymous access to creating webform components, which seldom be desired. * * @see webform_node_update_access(). * * @param object $node * The Webform node to check access on. * @param object $account * The user account to check access on. * @return boolean|NULL * TRUE or FALSE if the user can access the webform results, or NULL if * access should be deferred to other implementations of this hook or * $node->access('update') plus * $account->hasPermission('edit webform components'). */ function hook_webform_update_access($node, $account) { // Allow anyone who can see webform_editable_by_user nodes and who has // 'my webform component edit access' permission to see, edit, and delete the // webform components, e-mails, conditionals, and form settings. if ($node->bundle() == 'webform_editable_by_user') { return $node->access('view', $account) && $account->hasPermission('my webform component edit access'); } }
/** * Download a wiki file * * @param object $course \Components\Courses\Models\Course * @return void */ public function download($course) { // Get some needed libraries if (!$course->access('view')) { App::abort(404, Lang::txt('COM_COURSES_NO_COURSE_FOUND')); return; } // Get the scope of the parent page the file is attached to $filename = Request::getVar('file', ''); if (substr(strtolower($filename), 0, strlen('image:')) == 'image:') { $filename = substr($filename, strlen('image:')); } else { if (substr(strtolower($filename), 0, strlen('file:')) == 'file:') { $filename = substr($filename, strlen('file:')); } } $filename = urldecode($filename); // Get the configured upload path $config = Component::params('com_courses'); $base_path = $this->path($course->get('id')); // Does the path start with a slash? $filename = DS . ltrim($filename, DS); // Does the beginning of the $attachment->path match the config path? if (substr($filename, 0, strlen($base_path)) == $base_path) { // Yes - this means the full path got saved at some point } else { // No - append it $filename = $base_path . $filename; } // Add PATH_CORE $filename = PATH_APP . $filename; // Ensure the file exist if (!file_exists($filename)) { App::abort(404, Lang::txt('COM_COURSES_FILE_NOT_FOUND') . ' ' . $filename); return; } // Initiate a new content server and serve up the file $xserver = new \Hubzero\Content\Server(); $xserver->filename($filename); $xserver->disposition('inline'); $xserver->acceptranges(false); // @TODO fix byte range support if (!$xserver->serve()) { // Should only get here on error App::abort(404, Lang::txt('COM_COURSES_SERVER_ERROR')); } else { exit; } return; }
/** * Event call to get side content for main project page * Will show recent visits and who is online * * @param object $model * @return mixed */ public function onProjectMiniList($model) { if (!$model->exists() || !$model->access('content')) { return false; } // Get team $team = $model->team(); // Display team visits only on multiple-member projects if (count($team) == 1) { return false; } $view = new \Hubzero\Plugin\View(array('folder' => 'projects', 'element' => 'team', 'name' => 'mini')); $view->team = $team; $view->model = $model; return $view->loadTemplate(); }
/** * Show access message * * @param object $publication Publication object * @param string $option Component name * @param boolean $authorized * @param boolean $restricted * @param string $editlink * @return string HTML */ public static function showAccessMessage($publication) { $msg = ''; // Show message to restricted users if (!$publication->access('view-all')) { $class = 'warning'; switch ($publication->access) { case 1: $msg = Lang::txt('COM_PUBLICATIONS_STATUS_MSG_REGISTERED'); break; case 2: $msg = Lang::txt('COM_PUBLICATIONS_STATUS_MSG_RESTRICTED'); break; case 3: $msg = Lang::txt('COM_PUBLICATIONS_STATUS_MSG_PRIVATE'); break; } } elseif ($publication->access('manage')) { if ($publication->project()->isProvisioned() == 0) { $project = Lang::txt('COM_PUBLICATIONS_FROM_PROJECT'); $project .= $publication->access('owner') ? ' <a href="' . Route::url($publication->project()->link()) . '">' : ' <strong>'; $project .= \Hubzero\Utility\String::truncate($publication->project()->get('title'), 50); $project .= $publication->access('owner') ? '</a>' : '</strong>'; $msg .= ' <span class="fromproject">' . $project . '</span>'; } $class = 'info'; switch ($publication->version->get('state')) { case 1: $m = $publication->isDown() ? Lang::txt('COM_PUBLICATIONS_STATUS_MSG_UNPUBLISHED') : Lang::txt('COM_PUBLICATIONS_STATUS_MSG_PUBLISHED'); $m .= ' '; switch ($publication->get('access')) { case 0: $m .= Lang::txt('COM_PUBLICATIONS_STATUS_MSG_WITH_PUBLIC'); break; case 1: $m .= Lang::txt('COM_PUBLICATIONS_STATUS_MSG_WITH_REGISTERED'); break; case 2: $m .= Lang::txt('COM_PUBLICATIONS_STATUS_MSG_WITH_RESTRICTED'); break; case 3: $m .= Lang::txt('COM_PUBLICATIONS_STATUS_MSG_WITH_PRIVATE'); break; } if ($publication->isEmbargoed()) { $m = Lang::txt('COM_PUBLICATIONS_STATUS_MSG_PUBLISHED_EMBARGO') . ' ' . Date::of($publication->published_up)->toLocal('m d, Y'); } $msg .= $m; break; case 4: $msg .= Lang::txt('COM_PUBLICATIONS_STATUS_MSG_POSTED'); break; case 3: $msg .= $publication->versionCount() ? Lang::txt('COM_PUBLICATIONS_STATUS_MSG_DRAFT_VERSION') : Lang::txt('COM_PUBLICATIONS_STATUS_MSG_DRAFT'); break; case 0: $msg .= $publication->versionProperty('state', 'default') == 0 ? Lang::txt('COM_PUBLICATIONS_STATUS_MSG_UNPUBLISHED') : Lang::txt('COM_PUBLICATIONS_STATUS_MSG_UNPUBLISHED_VERSION'); break; case 5: $msg .= $publication->versionCount() ? Lang::txt('COM_PUBLICATIONS_STATUS_MSG_PENDING') : Lang::txt('COM_PUBLICATIONS_STATUS_MSG_PENDING_VERSION'); break; case 7: $msg .= Lang::txt('COM_PUBLICATIONS_STATUS_MSG_WIP'); break; } if ($publication->access('curator') && !$publication->access('owner') && !$publication->isPublished()) { $msg .= ' ' . Lang::txt('You are viewing this publication as a curator.'); } if ($publication->access('owner')) { // Build pub url $route = $publication->project()->isProvisioned() == 1 ? 'index.php?option=com_publications&task=submit' : 'index.php?option=com_projects&alias=' . $publication->project()->get('alias') . '&active=publications'; $msg .= ' <a href="' . Route::url($publication->link('editversion')) . '">' . Lang::txt('COM_PUBLICATIONS_STATUS_MSG_MANAGE_PUBLICATION') . '</a>.'; } } if ($msg) { return '<p class="' . $class . ' statusmsg">' . $msg . '</p>'; } return false; }
/** * Event call to return data for a specific project * * @param object $model Project model * @param string $action Plugin task * @param string $areas Plugins to return data * @param string $tool Name of tool wiki belongs to * @return array Return array of html */ public function onProject($model, $action = '', $areas = null, $tool = NULL) { $returnhtml = true; $arr = array('html' => '', 'metadata' => ''); // Get this area details $this->_area = $this->onProjectAreas(); // Check if our area is in the array of areas we want to return results for if (is_array($areas)) { if (empty($this->_area) || !in_array($this->_area['name'], $areas)) { return; } } // Check that project exists if (!$model->exists()) { return $arr; } // Check authorization if (!$model->access('member')) { return $arr; } // Model $this->model = $model; // Are we returning HTML? if ($returnhtml) { // Load wiki language file Lang::load('com_wiki') || Lang::load('com_wiki', PATH_CORE . DS . 'components' . DS . 'com_wiki' . DS . 'site'); // Set vars $this->_database = App::get('db'); $this->_uid = User::get('id'); // Load component configs $this->_config = $model->config(); $this->_group = $this->_config->get('group_prefix', 'pr-') . $this->model->get('alias'); // Incoming $this->_pagename = trim(Request::getVar('pagename', '', 'default', 'none', 2)); $this->_masterScope = 'projects' . DS . $this->model->get('alias') . DS . 'notes'; // Get our model $this->note = new \Components\Projects\Models\Note($this->_masterScope, $this->_group, $this->model->get('id')); // What's the task? $this->_task = $action ? $action : Request::getVar('action', 'view'); // Publishing? if ($this->_task == 'browser') { return $this->browser(); } // Import some needed libraries switch ($this->_task) { case 'upload': case 'download': case 'deletefolder': case 'deletefile': case 'media': case 'list': $this->_controllerName = 'media'; break; case 'history': case 'compare': case 'approve': case 'deleterevision': $this->_controllerName = 'history'; break; case 'editcomment': case 'addcomment': case 'savecomment': case 'reportcomment': case 'removecomment': case 'comments': $this->_controllerName = 'comments'; $cid = Request::getVar('cid', 0); if ($cid) { Request::setVar('comment', $cid); } break; case 'delete': case 'edit': case 'save': case 'rename': case 'saverename': default: $this->_controllerName = 'page'; break; } if (substr(strtolower($this->_pagename), 0, strlen('image:')) == 'image:' || substr(strtolower($this->_pagename), 0, strlen('file:')) == 'file:') { $this->_controllerName = 'media'; $this->_task = 'download'; } if (!file_exists(PATH_CORE . DS . 'components' . DS . 'com_wiki' . DS . 'site' . DS . 'controllers' . DS . $this->_controllerName . '.php')) { $this->_controllerName = 'page'; } // Include controller require_once PATH_CORE . DS . 'components' . DS . 'com_wiki' . DS . 'site' . DS . 'controllers' . DS . $this->_controllerName . '.php'; // Listing/unlisting? if ($this->_task == 'publist' || $this->_task == 'unlist') { $arr['html'] = $this->_list(); } elseif ($this->_task == 'share') { $arr['html'] = $this->_share(); } else { // Display page $arr['html'] = $this->page(); } } // Return data return $arr; }
/** * Event call to return data for a specific project * * @param object $model Project model * @param string $action Plugin task * @param string $areas Plugins to return data * @return array Return array of html */ public function onProject($model, $action = '', $areas = NULL) { $returnhtml = true; $arr = array('html' => '', 'metadata' => ''); // Get this area details $this->_area = $this->onProjectAreas(); // Check if our area is in the array of areas we want to return results for if (is_array($areas)) { if (empty($this->_area) || !in_array($this->_area['name'], $areas)) { return; } } // Check that project exists if (!$model->exists()) { return $arr; } // Check authorization if (!$model->access('member')) { return $arr; } // Model $this->model = $model; // Are we returning HTML? if ($returnhtml) { // Set vars $this->_config = $model->config(); $this->_task = Request::getVar('action', ''); $this->_database = App::get('db'); $this->_uid = User::get('id'); switch ($this->_task) { case 'page': default: $arr['html'] = $this->page(); break; case 'delete': $arr['html'] = $this->_delete(); break; case 'save': $arr['html'] = $this->_save(); break; case 'savecomment': $arr['html'] = $this->_saveComment(); break; case 'deletecomment': $arr['html'] = $this->_deleteComment(); break; case 'update': $arr['html'] = $this->updateFeed(); break; } } // Return data return $arr; }
/** * Event call to get side content for main project page * * @param object $model * @return string */ public function onProjectMiniList($model) { if (!$model->exists() || !$model->access('content')) { return false; } $this->repo = new \Components\Projects\Models\Repo($model, 'local'); $view = new \Hubzero\Plugin\View(array('folder' => 'projects', 'element' => 'files', 'name' => 'mini')); // Set params $view->params = array('limit' => $model->config()->get('sidebox_limit', 5), 'start' => 0, 'sortby' => 'modified', 'sortdir' => 'DESC', 'getParents' => false, 'getChildren' => false); // Retrieve items $view->files = $this->repo->filelist($view->params); $view->model = $model; return $view->loadTemplate(); }
/** * Event call to get side content for main project page * * @param object $model * @return mixed */ public function onProjectMiniList($model) { if (!$model->exists() || !$model->access('content')) { return false; } $view = new \Hubzero\Plugin\View(array('folder' => 'projects', 'element' => 'notes', 'name' => 'mini')); $group = $model->config()->get('group_prefix', 'pr-') . $model->get('alias'); $masterScope = 'projects' . DS . $model->get('alias') . DS . 'notes'; // Get our model $note = new \Components\Projects\Models\Note($masterScope, $group, $model->get('id')); $view->notes = $note->getNotes(); $view->model = $model; return $view->loadTemplate(); }