AAAAhome/academiac/www/administrator/components/com_content/controllers/article.php 0000644 00000007072 15137206777 0024313 0 ustar 00 view_list = 'featured'; $this->view_item = 'article&return=featured'; } parent::__construct($config); } /** * Method override to check if you can add a new record. * * @param array $data An array of input data. * * @return boolean * * @since 1.6 */ protected function allowAdd($data = array()) { // Initialise variables. $user = JFactory::getUser(); $categoryId = JArrayHelper::getValue($data, 'catid', JRequest::getInt('filter_category_id'), 'int'); $allow = null; if ($categoryId) { // If the category has been passed in the data or URL check it. $allow = $user->authorise('core.create', 'com_content.category.' . $categoryId); } if ($allow === null) { // In the absense of better information, revert to the component permissions. return parent::allowAdd(); } else { return $allow; } } /** * Method override to check if you can edit an existing record. * * @param array $data An array of input data. * @param string $key The name of the key for the primary key. * * @return boolean * * @since 1.6 */ protected function allowEdit($data = array(), $key = 'id') { // Initialise variables. $recordId = (int) isset($data[$key]) ? $data[$key] : 0; $user = JFactory::getUser(); $userId = $user->get('id'); // Check general edit permission first. if ($user->authorise('core.edit', 'com_content.article.' . $recordId)) { return true; } // Fallback on edit.own. // First test if the permission is available. if ($user->authorise('core.edit.own', 'com_content.article.' . $recordId)) { // Now test the owner is the user. $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; if (empty($ownerId) && $recordId) { // Need to do a lookup from the model. $record = $this->getModel()->getItem($recordId); if (empty($record)) { return false; } $ownerId = $record->created_by; } // If the owner matches 'me' then do the test. if ($ownerId == $userId) { return true; } } // Since there is no asset tracking, revert to the component permissions. return parent::allowEdit($data, $key); } /** * Method to run batch operations. * * @param object $model The model. * * @return boolean True if successful, false otherwise and internal error is set. * * @since 1.6 */ public function batch($model = null) { JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); // Set the model $model = $this->getModel('Article', '', array()); // Preset the redirect $this->setRedirect(JRoute::_('index.php?option=com_content&view=articles' . $this->getRedirectToListAppend(), false)); return parent::batch($model); } } home/academiac/www/plugins/editors-xtd/article/article.php 0000644 00000003753 15137253466 0017741 0 ustar 00 loadLanguage(); } /** * Display the button * * @return array A four element array of (article_id, article_title, category_id, object) */ function onDisplay($name) { /* * Javascript to insert the link * View element calls jSelectArticle when an article is clicked * jSelectArticle creates the link tag, sends it to the editor, * and closes the select frame. */ $js = " function jSelectArticle(id, title, catid, object, link, lang) { var hreflang = ''; if (lang !== '') { var hreflang = ' hreflang = \"' + lang + '\"'; } var tag = '' + title + ''; jInsertEditorText(tag, '".$name."'); SqueezeBox.close(); }"; $doc = JFactory::getDocument(); $doc->addScriptDeclaration($js); JHtml::_('behavior.modal'); /* * Use the built-in element view to select the article. * Currently uses blank class. */ $link = 'index.php?option=com_content&view=articles&layout=modal&tmpl=component&'.JSession::getFormToken().'=1'; $button = new JObject(); $button->set('modal', true); $button->set('link', $link); $button->set('text', JText::_('PLG_ARTICLE_BUTTON_ARTICLE')); $button->set('name', 'article'); $button->set('options', "{handler: 'iframe', size: {x: 770, y: 400}}"); return $button; } } home/academiac/www/administrator/components/com_content/elements/article.php 0000644 00000004037 15137341770 0023550 0 ustar 00 getTemplate(); $fieldName = $control_name.'['.$name.']'; $article = JTable::getInstance('content'); if ($value) { $article->load($value); } else { $article->title = JText::_('COM_CONTENT_SELECT_AN_ARTICLE'); } $js = " function jSelectArticle_".$name."(id, title, catid, object) { document.getElementById(object + '_id').value = id; document.getElementById(object + '_name').value = title; SqueezeBox.close(); }"; $doc->addScriptDeclaration($js); $link = 'index.php?option=com_content&task=element&tmpl=component&function=jSelectArticle_'.$name; JHtml::_('behavior.modal', 'a.modal'); $html = "\n".'
'; // $html .= "\n "; $html .= ''."\n"; $html .= "\n".''; return $html; } } home/academiac/www/components/com_content/controllers/article.php 0000644 00000016571 15137440473 0021430 0 ustar 00 setRedirect($this->getReturnPage()); } } /** * Method override to check if you can add a new record. * * @param array An array of input data. * * @return boolean * @since 1.6 */ protected function allowAdd($data = array()) { // Initialise variables. $user = JFactory::getUser(); $categoryId = JArrayHelper::getValue($data, 'catid', JRequest::getInt('catid'), 'int'); $allow = null; if ($categoryId) { // If the category has been passed in the data or URL check it. $allow = $user->authorise('core.create', 'com_content.category.'.$categoryId); } if ($allow === null) { // In the absense of better information, revert to the component permissions. return parent::allowAdd(); } else { return $allow; } } /** * Method override to check if you can edit an existing record. * * @param array $data An array of input data. * @param string $key The name of the key for the primary key. * * @return boolean * @since 1.6 */ protected function allowEdit($data = array(), $key = 'id') { // Initialise variables. $recordId = (int) isset($data[$key]) ? $data[$key] : 0; $user = JFactory::getUser(); $userId = $user->get('id'); $asset = 'com_content.article.'.$recordId; // Check general edit permission first. if ($user->authorise('core.edit', $asset)) { return true; } // Fallback on edit.own. // First test if the permission is available. if ($user->authorise('core.edit.own', $asset)) { // Now test the owner is the user. $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; if (empty($ownerId) && $recordId) { // Need to do a lookup from the model. $record = $this->getModel()->getItem($recordId); if (empty($record)) { return false; } $ownerId = $record->created_by; } // If the owner matches 'me' then do the test. if ($ownerId == $userId) { return true; } } // Since there is no asset tracking, revert to the component permissions. return parent::allowEdit($data, $key); } /** * Method to cancel an edit. * * @param string $key The name of the primary key of the URL variable. * * @return Boolean True if access level checks pass, false otherwise. * @since 1.6 */ public function cancel($key = 'a_id') { parent::cancel($key); // Redirect to the return page. $this->setRedirect($this->getReturnPage()); } /** * Method to edit an existing record. * * @param string $key The name of the primary key of the URL variable. * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). * * @return Boolean True if access level check and checkout passes, false otherwise. * @since 1.6 */ public function edit($key = null, $urlVar = 'a_id') { $result = parent::edit($key, $urlVar); return $result; } /** * Method to get a model object, loading it if required. * * @param string $name The model name. Optional. * @param string $prefix The class prefix. Optional. * @param array $config Configuration array for model. Optional. * * @return object The model. * * @since 1.5 */ public function getModel($name = 'form', $prefix = '', $config = array('ignore_request' => true)) { $model = parent::getModel($name, $prefix, $config); return $model; } /** * Gets the URL arguments to append to an item redirect. * * @param int $recordId The primary key id for the item. * @param string $urlVar The name of the URL variable for the id. * * @return string The arguments to append to the redirect URL. * @since 1.6 */ protected function getRedirectToItemAppend($recordId = null, $urlVar = 'a_id') { // Need to override the parent method completely. $tmpl = JRequest::getCmd('tmpl'); $layout = JRequest::getCmd('layout', 'edit'); $append = ''; // Setup redirect info. if ($tmpl) { $append .= '&tmpl='.$tmpl; } // TODO This is a bandaid, not a long term solution. // if ($layout) { // $append .= '&layout='.$layout; // } $append .= '&layout=edit'; if ($recordId) { $append .= '&'.$urlVar.'='.$recordId; } $itemId = JRequest::getInt('Itemid'); $return = $this->getReturnPage(); $catId = JRequest::getInt('catid', null, 'get'); if ($itemId) { $append .= '&Itemid='.$itemId; } if($catId) { $append .= '&catid='.$catId; } if ($return) { $append .= '&return='.base64_encode(urlencode($return)); } return $append; } /** * Get the return URL. * * If a "return" variable has been passed in the request * * @return string The return URL. * @since 1.6 */ protected function getReturnPage() { $return = JRequest::getVar('return', null, 'default', 'base64'); if (empty($return) || !JUri::isInternal(urldecode(base64_decode($return)))) { return JURI::base(); } else { return urldecode(base64_decode($return)); } } /** * Function that allows child controller access to model data after the data has been saved. * * @param JModel $model The data model object. * @param array $validData The validated data. * * @return void * @since 1.6 */ protected function postSaveHook(JModel &$model, $validData) { $task = $this->getTask(); if ($task == 'save') { $this->setRedirect(JRoute::_('index.php?option=com_content&view=category&id='.$validData['catid'], false)); } } /** * Method to save a record. * * @param string $key The name of the primary key of the URL variable. * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). * * @return Boolean True if successful, false otherwise. * @since 1.6 */ public function save($key = null, $urlVar = 'a_id') { // Load the backend helper for filtering. require_once JPATH_ADMINISTRATOR.'/components/com_content/helpers/content.php'; $result = parent::save($key, $urlVar); // If ok, redirect to the return page. if ($result) { $this->setRedirect($this->getReturnPage()); } return $result; } /** * Method to save a vote. * * @return void * @since 1.6.1 */ function vote() { // Check for request forgeries. JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $user_rating = JRequest::getInt('user_rating', -1); if ( $user_rating > -1 ) { $url = JRequest::getString('url', ''); $id = JRequest::getInt('id', 0); $viewName = JRequest::getString('view', $this->default_view); $model = $this->getModel($viewName); if ($model->storeVote($id, $user_rating)) { $this->setRedirect($url, JText::_('COM_CONTENT_ARTICLE_VOTE_SUCCESS')); } else { $this->setRedirect($url, JText::_('COM_CONTENT_ARTICLE_VOTE_FAILURE')); } } } }