Example #1
0
 /**
  * Execute a task
  *
  * @return     void
  */
 public function execute()
 {
     $this->warehouse = new Warehouse();
     $user = User::getRoot();
     $this->warehouse->addAccessLevels($user->getAuthorisedViewLevels());
     parent::execute();
 }
Example #2
0
 /**
  * Execute a task
  *
  * @return     void
  */
 public function execute()
 {
     $this->warehouse = new Warehouse();
     $user = User::getRoot();
     $this->warehouse->addAccessLevels($user->getAuthorisedViewLevels());
     // Get the task
     $this->_task = Request::getCmd('task', '');
     if (empty($this->_task)) {
         $this->_task = 'home';
         $this->registerTask('__default', $this->_task);
     }
     $executed = false;
     if (!method_exists($this, $this->_task . 'Task')) {
         // Try to find a corresponding collection
         $cId = $this->warehouse->collectionExists($this->_task);
         if ($cId) {
             // if match is found -- browse collection
             $executed = true;
             $this->browseCollection($cId);
         } else {
             App::abort(404, Lang::txt('Collection Not Found'));
         }
     }
     if (!$executed) {
         parent::execute();
     }
 }
Example #3
0
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $state = $this->get('State');
     $items = $this->get('Items');
     $pagination = $this->get('Pagination');
     // Get the page/component configuration
     $params =& $state->params;
     foreach ($items as $item) {
         $item->catslug = $item->category_alias ? $item->catid . ':' . $item->category_alias : $item->catid;
         $item->parent_slug = $item->parent_alias ? $item->parent_id . ':' . $item->parent_alias : $item->parent_id;
     }
     $form = new stdClass();
     // Month Field
     $months = array('' => Lang::txt('COM_CONTENT_MONTH'), '01' => Lang::txt('JANUARY_SHORT'), '02' => Lang::txt('FEBRUARY_SHORT'), '03' => Lang::txt('MARCH_SHORT'), '04' => Lang::txt('APRIL_SHORT'), '05' => Lang::txt('MAY_SHORT'), '06' => Lang::txt('JUNE_SHORT'), '07' => Lang::txt('JULY_SHORT'), '08' => Lang::txt('AUGUST_SHORT'), '09' => Lang::txt('SEPTEMBER_SHORT'), '10' => Lang::txt('OCTOBER_SHORT'), '11' => Lang::txt('NOVEMBER_SHORT'), '12' => Lang::txt('DECEMBER_SHORT'));
     $form->monthField = Html::select('genericlist', $months, 'month', array('list.attr' => 'size="1" class="inputbox"', 'list.select' => $state->get('filter.month'), 'option.key' => null));
     // Year Field
     $years = array();
     $years[] = Html::select('option', null, Lang::txt('JYEAR'));
     for ($i = 2000; $i <= 2020; $i++) {
         $years[] = Html::select('option', $i, $i);
     }
     $form->yearField = Html::select('genericlist', $years, 'year', array('list.attr' => 'size="1" class="inputbox"', 'list.select' => $state->get('filter.year')));
     $form->limitField = $pagination->getLimitBox();
     //Escape strings for HTML output
     $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
     $this->filter = $state->get('list.filter');
     $this->assignRef('form', $form);
     $this->assignRef('items', $items);
     $this->assignRef('params', $params);
     $this->assignRef('user', User::getRoot());
     $this->assignRef('pagination', $pagination);
     $this->_prepareDocument();
     parent::display($tpl);
 }
Example #4
0
 function display($tpl = null)
 {
     $user = User::getRoot();
     // If this is an auth_link account update, carry on, otherwise raise an error
     if (!is_object($user) || !array_key_exists('auth_link_id', $user) || !is_numeric($user->get('username')) || !$user->get('username') < 0) {
         App::abort('405', 'Method not allowed');
         return;
     }
     // Get and add the js and extra css to the page
     \Hubzero\Document\Assets::addComponentStylesheet('com_users', 'link.css');
     \Hubzero\Document\Assets::addComponentStylesheet('com_users', 'providers.css');
     \Hubzero\Document\Assets::addComponentScript('com_users', 'link');
     // Import a few things
     jimport('joomla.user.helper');
     // Look up a few things
     $hzal = \Hubzero\Auth\Link::find_by_id($user->get("auth_link_id"));
     $hzad = \Hubzero\Auth\Domain::find_by_id($hzal->auth_domain_id);
     $plugins = Plugin::byType('authentication');
     // Get the display name for the current plugin being used
     Plugin::import('authentication', $hzad->authenticator);
     $plugin = Plugin::byType('authentication', $hzad->authenticator);
     $pparams = new \Hubzero\Config\Registry($plugin->params);
     $refl = new ReflectionClass("plgAuthentication{$plugin->name}");
     $display_name = $pparams->get('display_name', $refl->hasMethod('onGetLinkDescription') ? $refl->getMethod('onGetLinkDescription')->invoke(NULL) : ucfirst($plugin->name));
     // Look for conflicts - first check in the hub accounts
     $profile_conflicts = \Hubzero\User\Profile\Helper::find_by_email($hzal->email);
     // Now check the auth_link table
     $link_conflicts = \Hubzero\Auth\Link::find_by_email($hzal->email, array($hzad->id));
     $conflict = array();
     if ($profile_conflicts) {
         foreach ($profile_conflicts as $p) {
             $user_id = JUserHelper::getUserId($p);
             $juser = User::getInstance($user_id);
             $auth_link = \Hubzero\Auth\Link::find_by_user_id($juser->id);
             $dname = is_object($auth_link) && $auth_link->auth_domain_name ? $auth_link->auth_domain_name : 'hubzero';
             $conflict[] = array("auth_domain_name" => $dname, "name" => $juser->name, "email" => $juser->email);
         }
     }
     if ($link_conflicts) {
         foreach ($link_conflicts as $l) {
             $juser = User::getInstance($l['user_id']);
             $conflict[] = array("auth_domain_name" => $l['auth_domain_name'], "name" => $juser->name, "email" => $l['email']);
         }
     }
     // Make sure we don't somehow have any duplicate conflicts
     $conflict = array_map("unserialize", array_unique(array_map("serialize", $conflict)));
     // @TODO: Could also check for high probability of name matches???
     // Get the site name
     $sitename = Config::get('sitename');
     // Assign variables to the view
     $this->assign('hzal', $hzal);
     $this->assign('hzad', $hzad);
     $this->assign('plugins', $plugins);
     $this->assign('display_name', $display_name);
     $this->assign('conflict', $conflict);
     $this->assign('sitename', $sitename);
     $this->assignref('juser', $user);
     parent::display($tpl);
 }
 public function __construct(&$subject, $config)
 {
     parent::__construct($subject, $config);
     // Ensure that constructor is called one time
     self::$cookie = SID == '';
     if (!self::$default_lang) {
         $app = JFactory::getApplication();
         $router = $app->getRouter();
         if (App::isSite()) {
             // setup language data
             self::$mode_sef = $router->getMode() == JROUTER_MODE_SEF ? true : false;
             self::$sefs = JLanguageHelper::getLanguages('sef');
             self::$lang_codes = JLanguageHelper::getLanguages('lang_code');
             self::$default_lang = Component::params('com_languages')->get('site', 'en-GB');
             self::$default_sef = self::$lang_codes[self::$default_lang]->sef;
             self::$homes = MultilangstatusHelper::getHomepages();
             $user = User::getRoot();
             $levels = $user->getAuthorisedViewLevels();
             foreach (self::$sefs as $sef => &$language) {
                 if (isset($language->access) && $language->access && !in_array($language->access, $levels)) {
                     unset(self::$sefs[$sef]);
                 }
             }
             App::forget('language.filter');
             App::set('language.filter', true);
             $uri = JFactory::getURI();
             if (self::$mode_sef) {
                 // Get the route path from the request.
                 $path = JString::substr($uri->toString(), JString::strlen($uri->base()));
                 // Apache mod_rewrite is Off
                 $path = Config::get('sef_rewrite') ? $path : JString::substr($path, 10);
                 // Trim any spaces or slashes from the ends of the path and explode into segments.
                 $path = JString::trim($path, '/ ');
                 $parts = explode('/', $path);
                 // The language segment is always at the beginning of the route path if it exists.
                 $sef = $uri->getVar('lang');
                 if (!empty($parts) && empty($sef)) {
                     $sef = reset($parts);
                 }
             } else {
                 $sef = $uri->getVar('lang');
             }
             if (isset(self::$sefs[$sef])) {
                 $lang_code = self::$sefs[$sef]->lang_code;
                 // Create a cookie
                 $cookie_domain = Config::get('cookie_domain', '');
                 $cookie_path = Config::get('cookie_path', '/');
                 setcookie(App::hash('language'), $lang_code, $this->getLangCookieTime(), $cookie_path, $cookie_domain);
                 // set the request var
                 Request::setVar('language', $lang_code);
             }
         }
         parent::__construct($subject, $config);
         // 	Detect browser feature
         if (App::isSite()) {
             $app->setDetectBrowser($this->params->get('detect_browser', '1') == '1');
         }
     }
 }
Example #6
0
 /**
  * Edit source feed form, load appropriate record
  *
  * @return  void
  */
 public function editTask()
 {
     //isset ID kinda deal
     $model = new Models\Feeds();
     $this->view->feed = $model->loadbyId(Request::getInt('id', 0));
     $this->view->user = User::getRoot();
     $this->view->title = Lang::txt('COM_FEEDAGGREGATOR_EDIT_FEEDS');
     $this->view->display();
 }
 /**
  * Main handler. Does all the checks
  *
  * @param 	void
  * @return 	void
  */
 public function audit()
 {
     /* If no user, some checks may be skipped... */
     // Get user
     $jUser = User::getRoot();
     // User specific checks
     if (!$jUser->get('guest')) {
         if ($sId = $this->getSku()) {
             // Check if the current user reached the max count of downloads for this SKU
             $sku = new Sku($sId);
             $skuDownloadLimit = $sku->getMeta('downloadLimit');
             if ($skuDownloadLimit > 0) {
                 // Get SKU download count
                 $skuDownloadCount = CartDownload::countUserSkuDownloads($this->sId, $this->uId);
                 // Check if the limit is reached
                 if ($skuDownloadCount >= $skuDownloadLimit) {
                     $this->setResponseStatus('error');
                     $this->setResponseNotice('You have reached the maximum number of allowed downloads for this product.');
                     $this->setResponseError(': you have reached the maximum number of allowed downloads for this product.');
                 }
             }
             return $this->getResponse();
         }
     }
     // Check SKU-related stuff if this is a SKU
     if ($sId = $this->getSku()) {
         // Check if SKU is reached the download max count
         $sku = new Sku($sId);
         $skuDownloadLimit = $sku->getMeta('globalDownloadLimit');
         if ($skuDownloadLimit > 0) {
             // Get SKU download count
             $skuDownloadCount = CartDownload::countSkuDownloads($this->sId);
             // Check if the limit is reached
             if ($skuDownloadCount >= $skuDownloadLimit) {
                 $this->setResponseStatus('error');
                 $this->setResponseNotice('This product has reached the maximum number of allowed downloads and cannot be downloaded.');
                 $this->setResponseError(': this product has reached the maximum number of allowed downloads and cannot be downloaded.');
             }
         }
         return $this->getResponse();
     }
     // Get product download limit
     $productDownloadLimit = Product::getMeta($this->pId, 'globalDownloadLimit');
     // Get product downloads count
     if ($productDownloadLimit > 0) {
         $productDownloadCount = CartDownload::countProductDownloads($this->pId);
         // Check if the limit is reached
         if ($productDownloadCount >= $productDownloadLimit) {
             $this->setResponseStatus('error');
             $this->setResponseNotice('This product has reached the maximum number of allowed downloads and cannot be downloaded.');
             $this->setResponseError(': this product has reached the maximum number of allowed downloads and cannot be downloaded.');
         }
     }
     return $this->getResponse();
 }
Example #8
0
 /**
  * Get a list of articles.
  *
  * @param   object  $params  The module parameters.
  * @return  mixed   An array of articles, or false on error.
  */
 public static function getList($params)
 {
     // Initialise variables
     $user = User::getRoot();
     // Get an instance of the generic articles model
     $model = \JModelLegacy::getInstance('Articles', 'ContentModel', array('ignore_request' => true));
     // Set List SELECT
     $model->setState('list.select', 'a.id, a.title, a.checked_out, a.checked_out_time, a.access, a.created, a.created_by, a.created_by_alias, a.featured, a.state');
     // Set Ordering filter
     switch ($params->get('ordering')) {
         case 'm_dsc':
             $model->setState('list.ordering', 'modified DESC, created');
             $model->setState('list.direction', 'DESC');
             break;
         case 'c_dsc':
         default:
             $model->setState('list.ordering', 'created');
             $model->setState('list.direction', 'DESC');
             break;
     }
     // Set Category Filter
     $categoryId = $params->get('catid');
     if (is_numeric($categoryId)) {
         $model->setState('filter.category_id', $categoryId);
     }
     // Set User Filter.
     $userId = $user->get('id');
     switch ($params->get('user_id')) {
         case 'by_me':
             $model->setState('filter.author_id', $userId);
             break;
         case 'not_me':
             $model->setState('filter.author_id', $userId);
             $model->setState('filter.author_id.include', false);
             break;
     }
     // Set the Start and Limit
     $model->setState('list.start', 0);
     $model->setState('list.limit', $params->get('count', 5));
     $items = $model->getItems();
     if ($error = $model->getError()) {
         throw new Exception($error, 500);
         return false;
     }
     // Set the links
     foreach ($items as &$item) {
         if ($user->authorise('core.edit', 'com_content.article.' . $item->id)) {
             $item->link = Route::url('index.php?option=com_content&task=article.edit&id=' . $item->id);
         } else {
             $item->link = '';
         }
     }
     return $items;
 }
Example #9
0
 /**
  * Execute a task
  *
  * @return     void
  */
 public function execute()
 {
     $this->warehouse = new Warehouse();
     $this->juser = User::getRoot();
     // Check if they're logged in
     if ($this->juser->get('guest')) {
         $this->login('Please login to continue');
         return;
     }
     parent::execute();
 }
Example #10
0
 /**
  * Gets a list of the actions that can be performed.
  *
  * @param	string	$extension	The extension.
  * @param	int		$categoryId	The category ID.
  *
  * @return	JObject
  * @since	1.6
  */
 public static function getActions($assetType = 'component', $assetId = 0)
 {
     $assetName = 'com_storefront';
     $user = User::getRoot();
     $result = new JObject();
     $assetName .= '.' . $assetType;
     if ($assetId) {
         $assetName .= '.' . (int) $assetId;
     }
     $actions = array('core.admin', 'core.manage', 'core.create', 'core.edit', 'core.edit.state', 'core.delete');
     foreach ($actions as $action) {
         $result->set($action, $user->authorise($action, $assetName));
     }
     return $result;
 }
Example #11
0
 /**
  * Gets a list of the actions that can be performed.
  *
  * @param   string   $extension  The extension.
  * @param   integer  $assetId    The category ID.
  * @return  object
  */
 public static function getActions($assetType = 'component', $assetId = 0)
 {
     $assetName = self::$extension;
     $assetName .= '.' . $assetType;
     if ($assetId) {
         $assetName .= '.' . (int) $assetId;
     }
     $user = \User::getRoot();
     $result = new Object();
     $actions = array('admin', 'manage', 'create', 'edit', 'edit.state', 'delete');
     foreach ($actions as $action) {
         $result->set('core.' . $action, $user->authorise($action, $assetName));
     }
     return $result;
 }
Example #12
0
 /**
  * Execute a task
  *
  * @return     void
  */
 public function execute()
 {
     // Get the task
     $this->_task = Request::getVar('task', '');
     if (empty($this->_task)) {
         $this->_task = 'checkout';
         $this->registerTask('__default', $this->_task);
     }
     $this->user = User::getRoot();
     // Check if they're logged in
     if (User::isGuest()) {
         $this->login('Please login to continue');
         return;
     }
     parent::execute();
 }
Example #13
0
 public function display($tpl = null)
 {
     // Initialise variables.
     $app = JFactory::getApplication();
     // Get model data.
     $this->state = $this->get('State');
     $this->item = $this->get('Item');
     $this->form = $this->get('Form');
     $this->return_page = $this->get('ReturnPage');
     if (empty($this->item->id)) {
         $authorised = User::authorise('core.create', 'com_content') || count(User::getAuthorisedCategories('com_content', 'core.create'));
     } else {
         $authorised = $this->item->params->get('access-edit');
     }
     if ($authorised !== true) {
         App::abort(403, Lang::txt('JERROR_ALERTNOAUTHOR'));
         return false;
     }
     if (!empty($this->item) && isset($this->item->id)) {
         $this->item->images = json_decode($this->item->images);
         $this->item->urls = json_decode($this->item->urls);
         $tmp = new stdClass();
         $tmp->images = $this->item->images;
         $tmp->urls = $this->item->urls;
         $this->form->bind($tmp);
     }
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         throw new Exception(implode("\n", $errors), 500);
         return false;
     }
     // Create a shortcut to the parameters.
     $params =& $this->state->params;
     //Escape strings for HTML output
     $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
     $this->params = $params;
     $this->user = User::getRoot();
     if ($params->get('enable_category') == 1) {
         $this->form->setFieldAttribute('catid', 'default', $params->get('catid', 1));
         $this->form->setFieldAttribute('catid', 'readonly', 'true');
     }
     $this->_prepareDocument();
     parent::display($tpl);
 }
 /**
  * Main handler. Does all the checks
  *
  * @param 	void
  * @return 	void
  */
 public function audit()
 {
     /* Membership may have a limit on when it can be extended */
     /* If no user, some checks may be skipped... */
     // Get user
     $jUser = User::getRoot();
     if (!$jUser->get('guest')) {
         // Check if there is a limitation on when the subscription can be extended
         $subscriptionMaxLen = Product::getMeta($this->pId, 'subscriptionMaxLen');
         if ($subscriptionMaxLen) {
             /* Check if the current user has the existing subscription and how much is left on it
             		 i.e. figure out if he may extend his current subscription */
             /*
              *  This is not working very well for multiple SKUs with multiple subscriptionMaxLen's
              *  at this point code doesn't know what SKU will be added,
              *  so for one SKU subscriptionMaxLen should
              *  be set to time less than actual membership length, ie if membership is sold for 1 year and
              *  cannot be renewed more than 6 month before it expires the subscriptionMaxLen must be set to 6 MONTH
              *  if it cannot be renewed more than 3 month before it expires the subscriptionMaxLen must be set to 3 MONTH
              *
              *  so subscriptionMaxLen = XX is actually "let renew XX time before expiration"
              */
             // Get the proper product type subscription object reference
             $subscription = Memberships::getSubscriptionObject($this->type, $this->pId, $this->uId);
             // Get the expiration for the current subscription (if any)
             $currentExpiration = $subscription->getExpiration();
             if ($currentExpiration && $currentExpiration['crtmActive']) {
                 // Do the check
                 $currentExpirationTime = $currentExpiration['crtmExpires'];
                 // See if current expiration is later than max allowed time from now (max allowed time + now)
                 if (strtotime('+' . $subscriptionMaxLen) < strtotime($currentExpirationTime)) {
                     // Expiration is not allowed -- the current expiration is too far in the future
                     $this->setResponseStatus('error');
                     $this->setResponseNotice('You already have an active subscription to this item. Subscription extension is not available at this time.');
                     $this->setResponseError(': you already have an active subscription. Subscription extension is not available at this time.');
                 }
             }
         }
     }
     return $this->getResponse();
 }
Example #15
0
 /**
  * Display the button
  *
  * @return array A two element array of (imageName, textToInsert)
  */
 public function onDisplay($name, $asset, $author)
 {
     $params = Component::params('com_media');
     $user = User::getRoot();
     $extension = Request::getCmd('option');
     if ($asset == '') {
         $asset = $extension;
     }
     if ($user->authorise('core.edit', $asset) || $user->authorise('core.create', $asset) || count($user->getAuthorisedCategories($asset, 'core.create')) > 0 || $user->authorise('core.edit.own', $asset) && $author == $user->id || count($user->getAuthorisedCategories($extension, 'core.edit')) > 0 || count($user->getAuthorisedCategories($extension, 'core.edit.own')) > 0 && $author == $user->id) {
         $link = 'index.php?option=com_media&amp;view=images&amp;tmpl=component&amp;e_name=' . $name . '&amp;asset=' . $asset . '&amp;author=' . $author;
         Html::behavior('modal');
         $button = new \Hubzero\Base\Object();
         $button->set('modal', true);
         $button->set('link', $link);
         $button->set('text', Lang::txt('PLG_IMAGE_BUTTON_IMAGE'));
         $button->set('name', 'image');
         $button->set('options', "{handler: 'iframe', size: {x: 800, y: 500}}");
         return $button;
     } else {
         return false;
     }
 }
Example #16
0
 /**
  * Method to build an SQL query to load the list data.
  *
  * @return	string	An SQL query
  * @since	1.6
  */
 protected function getListQuery()
 {
     $user = User::getRoot();
     $groups = implode(',', $user->getAuthorisedViewLevels());
     // Create a new query object.
     $db = $this->getDbo();
     $query = $db->getQuery(true);
     // Select required fields from the categories.
     $query->select($this->getState('list.select', 'a.*'));
     $query->from($db->quoteName('#__newsfeeds') . ' AS a');
     $query->where('a.access IN (' . $groups . ')');
     // Filter by category.
     if ($categoryId = $this->getState('category.id')) {
         $query->where('a.catid = ' . (int) $categoryId);
         $query->join('LEFT', '#__categories AS c ON c.id = a.catid');
         $query->where('c.access IN (' . $groups . ')');
     }
     // Filter by state
     $state = $this->getState('filter.published');
     if (is_numeric($state)) {
         $query->where('a.published = ' . (int) $state);
     }
     // Filter by start and end dates.
     $nullDate = $db->Quote($db->getNullDate());
     $date = Date::of('now');
     $nowDate = $db->Quote($date->format($db->getDateFormat()));
     if ($this->getState('filter.publish_date')) {
         $query->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')');
         $query->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')');
     }
     // Filter by language
     if ($this->getState('filter.language')) {
         $query->where('a.language in (' . $db->Quote(Lang::getTag()) . ',' . $db->Quote('*') . ')');
     }
     // Add the list ordering clause.
     $query->order($db->escape($this->getState('list.ordering', 'a.ordering')) . ' ' . $db->escape($this->getState('list.direction', 'ASC')));
     return $query;
 }
Example #17
0
 /**
  * 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 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 = '';
         }
     }
     if ($rtrn == 'all' || $rtrn == 'html') {
         // Instantiate a view
         $view = $this->view('default', 'index');
         $view->option = $option;
         $view->model = $model;
         $view->database = App::get('db');
         $view->user = User::getRoot();
         $view->plugin = $this->params;
         $view->openurl = $this->getOpenUrl();
         // Return the output
         $arr['html'] = $view->loadTemplate();
     }
     return $arr;
 }
Example #18
0
 /**
  * Resource Import Record Constructor
  *
  * @param mixes  $raw     Raw Resource data
  * @param array  $options Import options
  */
 public function __construct($raw, $options = array(), $mode = 'UPDATE')
 {
     // store our incoming data
     $this->raw = $raw;
     $this->_options = $options;
     $this->_mode = $mode;
     // create core objects
     $this->_database = \App::get('db');
     $this->_user = \User::getRoot();
     // create resource objects
     $this->record = new stdClass();
     $this->record->resource = new Tables\Resource($this->_database);
     $this->record->type = new Tables\Type($this->_database);
     $this->record->children = array();
     $this->record->tags = array();
     $this->record->contributors = array();
     $this->record->custom = new stdClass();
     // message bags for user
     $this->record->errors = array();
     $this->record->notices = array();
     // bind data
     $this->bind();
 }
 /**
  * Return data on a group view (this will be some form of HTML)
  *
  * @param      object  $group      Current group
  * @param      string  $option     Name of the component
  * @param      string  $authorized User's authorization level
  * @param      integer $limit      Number of records to pull
  * @param      integer $limitstart Start of records to pull
  * @param      string  $action     Action to perform
  * @param      array   $access     What can be accessed
  * @param      array   $areas      Active area(s)
  * @return     array
  */
 public function onGroup($group, $option, $authorized, $limit = 0, $limitstart = 0, $action = '', $access, $areas = null)
 {
     // The output array we're returning
     $arr = array('html' => '');
     $user = User::getRoot();
     $this->group = $group;
     $this->option = $option;
     // Things we need from the form
     $recvEmailOptionID = Request::getInt('memberoptionid', 0);
     $recvEmailOptionValue = Request::getInt('recvpostemail', 0);
     include_once __DIR__ . DS . 'memberoption.class.php';
     switch ($action) {
         case 'editmemberoptions':
             $arr['html'] .= $this->edit($group, $user, $recvEmailOptionID, $recvEmailOptionValue);
             break;
         case 'savememberoptions':
             $arr['html'] .= $this->save($group, $user, $recvEmailOptionID, $recvEmailOptionValue);
             break;
         default:
             $arr['html'] .= $this->edit($group, $user, $recvEmailOptionID, $recvEmailOptionValue);
             break;
     }
     return $arr;
 }
Example #20
0
 /**
  * Example after save content method
  * Article is passed by reference, but after the save, so no changes will be saved.
  * Method is called right after the content is saved
  *
  * @param	string		The context of the content passed to the plugin (added in 1.6)
  * @param	object		A JTableContent object
  * @param	bool		If the content is just about to be created
  * @since	1.6
  */
 public function onContentAfterSave($context, &$article, $isNew)
 {
     // Check we are handling the frontend edit form.
     if ($context != 'com_content.form') {
         return true;
     }
     // Check if this function is enabled.
     if (!$this->params->def('email_new_fe', 1)) {
         return true;
     }
     // Check this is a new article.
     if (!$isNew) {
         return true;
     }
     $user = User::getRoot();
     // Messaging for new items
     JModelLegacy::addIncludePath(PATH_CORE . '/components/com_messages/admin/models', 'MessagesModel');
     JTable::addIncludePath(PATH_CORE . '/components/com_messages/admin/tables');
     $db = App::get('db');
     $db->setQuery('SELECT id FROM #__users WHERE sendEmail = 1');
     $users = (array) $db->loadColumn();
     $default_language = Component::params('com_languages')->get('administrator');
     $debug = Config::get('debug_lang');
     foreach ($users as $user_id) {
         if ($user_id != $user->id) {
             // Load language for messaging
             $receiver = User::getInstance($user_id);
             $lang = JLanguage::getInstance($receiver->getParam('admin_language', $default_language), $debug);
             $lang->load('com_content');
             $message = array('user_id_to' => $user_id, 'subject' => $lang->_('COM_CONTENT_NEW_ARTICLE'), 'message' => sprintf($lang->_('COM_CONTENT_ON_NEW_CONTENT'), $user->get('name'), $article->title));
             $model_message = JModelLegacy::getInstance('Message', 'MessagesModel');
             $model_message->save($message);
         }
     }
     return true;
 }
Example #21
0
 /**
  * Load published modules.
  *
  * @return  array
  */
 public function all()
 {
     static $clean;
     if (isset($clean)) {
         return $clean;
     }
     $Itemid = $this->app['request']->getInt('Itemid');
     $user = \User::getRoot();
     $groups = implode(',', $user->getAuthorisedViewLevels());
     $lang = $this->app['language']->getTag();
     $clientId = (int) $this->app['client']->id;
     $cache = $this->app['cache.store'];
     $cacheid = 'com_modules.' . md5(serialize(array($Itemid, $groups, $clientId, $lang)));
     if (!($clean = $cache->get($cacheid))) {
         $db = $this->app['db'];
         $query = $db->getQuery(true);
         $query->select('m.id, m.title, m.module, m.position, m.content, m.showtitle, m.params, mm.menuid');
         $query->from('#__modules AS m');
         $query->join('LEFT', '#__modules_menu AS mm ON mm.moduleid = m.id');
         $query->where('m.published = 1');
         $query->join('LEFT', '#__extensions AS e ON e.element = m.module AND e.client_id = m.client_id');
         $query->where('e.enabled = 1');
         $now = with(new Date('now'))->toSql();
         $nullDate = $db->getNullDate();
         $query->where('(m.publish_up = ' . $db->quote($nullDate) . ' OR m.publish_up <= ' . $db->quote($now) . ')');
         $query->where('(m.publish_down = ' . $db->quote($nullDate) . ' OR m.publish_down >= ' . $db->quote($now) . ')');
         $query->where('m.access IN (' . $groups . ')');
         $query->where('m.client_id = ' . $clientId);
         $query->where('(mm.menuid = ' . (int) $Itemid . ' OR mm.menuid <= 0)');
         // Filter by language
         if ($this->app->isSite() && $this->app->get('language.filter')) {
             $query->where('m.language IN (' . $db->quote($lang) . ',' . $db->quote('*') . ')');
         }
         $query->order('m.position, m.ordering');
         // Set the query
         $db->setQuery($query);
         $modules = $db->loadObjectList();
         $clean = array();
         if ($db->getErrorNum()) {
             $this->app['notification']->error($this->app['language']->txt('JLIB_APPLICATION_ERROR_MODULE_LOAD', $db->getErrorMsg()));
             return $clean;
         }
         // Apply negative selections and eliminate duplicates
         $negId = $Itemid ? -(int) $Itemid : false;
         $dupes = array();
         for ($i = 0, $n = count($modules); $i < $n; $i++) {
             $module =& $modules[$i];
             // The module is excluded if there is an explicit prohibition
             $negHit = $negId === (int) $module->menuid;
             if (isset($dupes[$module->id])) {
                 // If this item has been excluded, keep the duplicate flag set,
                 // but remove any item from the cleaned array.
                 if ($negHit) {
                     unset($clean[$module->id]);
                 }
                 continue;
             }
             $dupes[$module->id] = true;
             // Only accept modules without explicit exclusions.
             if (!$negHit) {
                 $module->name = substr($module->module, 4);
                 $module->style = null;
                 $module->position = strtolower($module->position);
                 $clean[$module->id] = $module;
             }
         }
         unset($dupes);
         // Return to simple indexing that matches the query order.
         $clean = array_values($clean);
         $cache->put($cacheid, $clean, $this->app['config']->get('cachetime', 15));
     }
     return $clean;
 }
Example #22
0
 /**
  * Constructor
  *
  * @param   array  $config  Optional configurations to be used
  * @return  void
  */
 public function __construct($config = array())
 {
     $this->_redirect = null;
     $this->_message = null;
     $this->_messageType = 'message';
     // Get the reflection info
     $r = new ReflectionClass($this);
     // Is it namespaced?
     if ($r->inNamespace()) {
         // It is! This makes things easy.
         $this->_controller = strtolower($r->getShortName());
     }
     // Set the name
     if (empty($this->_name)) {
         if (isset($config['name'])) {
             $this->_name = $config['name'];
         } else {
             $segments = null;
             $cls = $r->getName();
             // If namespaced...
             if (strstr($cls, '\\')) {
                 $segments = explode('\\', $cls);
             } else {
                 if (preg_match('/(.*)Controller(.*)/i', $cls, $segments)) {
                     $this->_controller = isset($segments[2]) ? strtolower($segments[2]) : null;
                 } else {
                     throw new InvalidControllerException(Lang::txt('Controller::__construct() : Can\'t get or parse class name.'), 500);
                 }
             }
             $this->_name = strtolower($segments[1]);
         }
     }
     // Set the base path
     if (array_key_exists('base_path', $config)) {
         $this->_basePath = $config['base_path'];
     } else {
         // Set base path relative to the controller file rather than
         // an absolute path. This gives us a little more flexibility.
         $this->_basePath = dirname(dirname($r->getFileName()));
     }
     // Set the component name
     $this->_option = 'com_' . $this->_name;
     // Determine the methods to exclude from the base class.
     $xMethods = get_class_methods('\\Hubzero\\Component\\SiteController');
     // Get all the public methods of this class
     foreach ($r->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {
         $name = $method->getName();
         // Ensure task isn't in the exclude list and ends in 'Task'
         if ((!in_array($name, $xMethods) || $name == 'displayTask') && substr(strtolower($name), -4) == 'task') {
             // Remove the 'Task' suffix
             $name = substr($name, 0, -4);
             // Auto register the methods as tasks.
             $this->_taskMap[strtolower($name)] = $name;
         }
     }
     // get language object & get any loaded lang for option
     $lang = \Lang::getRoot();
     $loaded = $lang->getPaths($this->_option);
     // Load language file if we dont have one yet
     if (!isset($loaded) || empty($loaded)) {
         $lang->load($this->_option, $this->_basePath . '/../..');
     }
     // Set some commonly used vars
     //
     // [!] Deprecated
     //     These will be going away in a future version. Do not use.
     $this->juser = \User::getRoot();
     $this->database = \App::get('db');
     $this->config = \Component::params($this->_option);
 }
Example #23
0
 /**
  * This method should handle any login logic and report back to the subject
  *
  * @param   array    $user     holds the user data
  * @param   array    $options  array holding options (remember, autoregister, group)
  * @return  boolean  True on success
  */
 public function onLoginUser($user, $options = array())
 {
     jimport('joomla.user.helper');
     $xuser = User::getRoot();
     // get user from session (might be tmp_user, can't fetch from db)
     if ($xuser->get('guest')) {
         // joomla user plugin hasn't run or something went very badly
         $plugins = Plugin::byType('user');
         $xuser_order = false;
         $joomla_order = false;
         $i = 0;
         foreach ($plugins as $plugin) {
             if ($plugin->name == 'xusers') {
                 $xuser_order = $i;
             }
             if ($plugin->name == 'joomla') {
                 $joomla_order = $i;
             }
             $i++;
         }
         if ($joomla_order === false) {
             return new Exception(Lang::txt('E_JOOMLA_USER_PLUGIN_MISCONFIGURED'), 500);
         }
         if ($xuser_order <= $joomla_order) {
             return new Exception(Lang::txt('E_HUBZERO_USER_PLUGIN_MISCONFIGURED'), 500);
         }
         return new Exception(Lang::txt('E_JOOMLA_USER_PLUGIN_FAILED'), 500);
     }
     // log login to auth log
     Log::auth($xuser->get('id') . ' [' . $xuser->get('username') . '] ' . $_SERVER['REMOTE_ADDR'] . ' login');
     // correct apache log data
     apache_note('auth', 'login');
     // Log attempt to the database
     Hubzero\User\User::oneOrFail($xuser->get('id'))->logger()->auth()->save(['username' => $xuser->get('username'), 'status' => 'success']);
     // update session tracking with new data
     $session = App::get('session');
     $session->set('tracker.user_id', $xuser->get('id'));
     $session->set('tracker.username', $xuser->get('username'));
     if ($session->get('tracker.sid') == '') {
         $session->set('tracker.sid', $session->getId());
     }
     $session->set('tracker.psid', $session->get('tracker.sid'));
     if ($session->get('tracker.rsid') == '') {
         $session->set('tracker.rsid', $session->getId());
     }
     if ($session->get('tracker.user_id') != $xuser->get('id') || $session->get('tracker.ssid') == '') {
         $session->set('tracker.ssid', $session->getId());
     }
     if (empty($user['type'])) {
         $session->clear('session.authenticator');
     } else {
         $session->set('session.authenticator', $user['type']);
     }
     if (isset($options['silent']) && $options['silent']) {
         $session->set('session.source', 'cookie');
     } else {
         $session->set('session.source', 'user');
     }
     // update tracking data with changes related to login
     jimport('joomla.utilities.utility');
     $hash = App::hash(App::get('client')->name . ':tracker');
     $key = \App::hash('');
     $crypt = new \Hubzero\Encryption\Encrypter(new \Hubzero\Encryption\Cipher\Simple(), new \Hubzero\Encryption\Key('simple', $key, $key));
     $tracker = array();
     $tracker['user_id'] = $session->get('tracker.user_id');
     $tracker['username'] = $session->get('tracker.username');
     $tracker['sid'] = $session->getId();
     $tracker['rsid'] = $session->get('tracker.rsid', $tracker['sid']);
     $tracker['ssid'] = $session->get('tracker.ssid', $tracker['sid']);
     $cookie = $crypt->encrypt(serialize($tracker));
     $lifetime = time() + 365 * 24 * 60 * 60;
     // Determine whether cookie should be 'secure' or not
     $secure = false;
     $forceSsl = \Config::get('force_ssl', false);
     if (\App::isAdmin() && $forceSsl >= 1) {
         $secure = true;
     } else {
         if (\App::isSite() && $forceSsl == 2) {
             $secure = true;
         }
     }
     setcookie($hash, $cookie, $lifetime, '/', '', $secure, true);
     /* Mark registration as incomplete so it gets checked on next page load */
     $username = $xuser->get('username');
     if (isset($user['auth_link']) && is_object($user['auth_link'])) {
         $hzal = $user['auth_link'];
     } else {
         $hzal = null;
     }
     if ($xuser->get('tmp_user')) {
         $email = $xuser->get('email');
         if ($username[0] == '-') {
             $username = trim($username, '-');
             if ($hzal) {
                 $xuser->set('username', 'guest;' . $username);
                 $xuser->set('email', $hzal->email);
             }
         }
     } else {
         if ($username[0] == '-') {
             $username = trim($username, '-');
             if ($hzal) {
                 $hzal->user_id = $xuser->get('id');
                 $hzal->update();
             }
         }
     }
     if ($hzal) {
         $xuser->set('auth_link_id', $hzal->id);
         $session->set('linkaccount', true);
     }
     $session->set('registration.incomplete', true);
     // Check if quota exists for the user
     $params = Component::params('com_members');
     if ($params->get('manage_quotas', false)) {
         require_once PATH_CORE . DS . 'components' . DS . 'com_members' . DS . 'tables' . DS . 'users_quotas.php';
         require_once PATH_CORE . DS . 'components' . DS . 'com_members' . DS . 'tables' . DS . 'quotas_classes.php';
         $quota = new \Components\Members\Tables\UsersQuotas($this->database);
         $quota->load(array('user_id' => $xuser->get('id')));
         if (!$quota->id) {
             $class = new \Components\Members\Tables\QuotasClasses($this->database);
             $class->load(array('alias' => 'default'));
             if ($class->id) {
                 $quota->set('user_id', $xuser->get('id'));
                 $quota->set('class_id', $class->id);
                 $quota->set('soft_blocks', $class->soft_blocks);
                 $quota->set('hard_blocks', $class->hard_blocks);
                 $quota->set('soft_files', $class->soft_files);
                 $quota->set('hard_files', $class->hard_files);
                 $quota->store();
             }
         } else {
             if ($quota->class_id) {
                 // Here, we're checking to make sure their class matches their actual quota values
                 $class = new \Components\Members\Tables\QuotasClasses($this->database);
                 $class->load($quota->class_id);
                 if ($quota->get('soft_blocks') != $class->get('soft_blocks') || $quota->get('hard_blocks') != $class->get('hard_blocks') || $quota->get('soft_files') != $class->get('soft_files') || $quota->get('hard_files') != $class->get('hard_files')) {
                     $quota->set('user_id', $xuser->get('id'));
                     $quota->set('class_id', $class->id);
                     $quota->set('soft_blocks', $class->soft_blocks);
                     $quota->set('hard_blocks', $class->hard_blocks);
                     $quota->set('soft_files', $class->soft_files);
                     $quota->set('hard_files', $class->hard_files);
                     $quota->store();
                 }
             }
         }
     }
     return true;
 }
Example #24
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::getRoot();
     $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 #25
0
 /**
  * Return data on a group view (this will be some form of HTML)
  *
  * @param      object  $group      Current group
  * @param      string  $option     Name of the component
  * @param      string  $authorized User's authorization level
  * @param      integer $limit      Number of records to pull
  * @param      integer $limitstart Start of records to pull
  * @param      string  $action     Action to perform
  * @param      array   $access     What can be accessed
  * @param      array   $areas      Active area(s)
  * @return     array
  */
 public function onGroup($group, $option, $authorized, $limit = 0, $limitstart = 0, $action = '', $access, $areas = null)
 {
     $returnhtml = true;
     $active = 'calendar';
     // The output array we're returning
     $arr = array('html' => '', 'metadata' => '');
     //get this area details
     $this_area = $this->onGroupAreas();
     // Check if our area is in the array of areas we want to return results for
     if (is_array($areas) && $limit) {
         if (!in_array($this_area['name'], $areas)) {
             $returnhtml = false;
         }
     }
     //Create user object
     $user = User::getRoot();
     //get the group members
     $members = $group->get('members');
     // Set some variables so other functions have access
     $this->user = $user;
     $this->authorized = $authorized;
     $this->members = $members;
     $this->group = $group;
     $this->option = $option;
     $this->action = $action;
     $this->access = $access;
     $this->event = null;
     //if we want to return content
     if ($returnhtml) {
         //set group members plugin access level
         $group_plugin_acl = $access[$active];
         //if were not trying to subscribe
         if ($this->action != 'subscribe') {
             //if set to nobody make sure cant access
             if ($group_plugin_acl == 'nobody') {
                 $arr['html'] = '<p class="info">' . Lang::txt('GROUPS_PLUGIN_OFF', ucfirst($active)) . '</p>';
                 return $arr;
             }
             //check if guest and force login if plugin access is registered or members
             if (User::isGuest() && ($group_plugin_acl == 'registered' || $group_plugin_acl == 'members')) {
                 $url = Route::url('index.php?option=com_groups&cn=' . $group->get('cn') . '&active=' . $active, false, true);
                 App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode($url)), Lang::txt('GROUPS_PLUGIN_REGISTERED', ucfirst($active)), 'warning');
                 return;
             }
             //check to see if user is member and plugin access requires members
             if (!in_array($user->get('id'), $members) && $group_plugin_acl == 'members') {
                 $arr['html'] = '<p class="info">' . Lang::txt('GROUPS_PLUGIN_REQUIRES_MEMBER', ucfirst($active)) . '</p>';
                 return $arr;
             }
         }
         // load events lang file
         Lang::load('com_events') || Lang::load('com_events', PATH_CORE . DS . 'components' . DS . 'com_events' . DS . 'site');
         //push styles to the view
         $this->css('calendar');
         $this->js('calendar');
         //get the request vars
         $this->month = Request::getInt('month', Date::format("m"), 'get');
         $this->month = strlen($this->month) == 1 ? '0' . $this->month : $this->month;
         $this->year = Request::getInt('year', Date::format("Y"), 'get');
         $this->calendar = Request::getInt('calendar', 0, 'get');
         // make sure month is always two digets
         if (strlen($this->month) == 1) {
             $this->month = 0 . $this->month;
         }
         //set vars for reuse purposes
         $this->database = App::get('db');
         //include needed event libs
         require __DIR__ . '/helper.php';
         require_once PATH_CORE . DS . 'components' . DS . 'com_events' . DS . 'models' . DS . 'event.php';
         require_once PATH_CORE . DS . 'components' . DS . 'com_events' . DS . 'models' . DS . 'calendar' . DS . 'archive.php';
         require_once PATH_CORE . DS . 'components' . DS . 'com_events' . DS . 'tables' . DS . 'respondent.php';
         require_once PATH_CORE . DS . 'components' . DS . 'com_events' . DS . 'helpers' . DS . 'html.php';
         //run task based on action
         switch ($this->action) {
             //managing events
             case 'add':
                 $arr['html'] = $this->add();
                 break;
             case 'edit':
                 $arr['html'] = $this->edit();
                 break;
             case 'save':
                 $arr['html'] = $this->save();
                 break;
             case 'delete':
                 $arr['html'] = $this->delete();
                 break;
             case 'details':
                 $arr['html'] = $this->details();
                 break;
             case 'export':
                 $arr['html'] = $this->export();
                 break;
             case 'subscribe':
                 $arr['html'] = $this->subscribe();
                 break;
             case 'import':
                 $arr['html'] = $this->import();
                 break;
                 //event registration
             //event registration
             case 'register':
                 $arr['html'] = $this->register();
                 break;
             case 'doregister':
                 $arr['html'] = $this->doRegister();
                 break;
             case 'registrants':
                 $arr['html'] = $this->registrants();
                 break;
             case 'download':
                 $arr['html'] = $this->download();
                 break;
                 //event calendars
             //event calendars
             case 'calendars':
                 $arr['html'] = $this->calendars();
                 break;
             case 'addcalendar':
                 $arr['html'] = $this->addCalendar();
                 break;
             case 'editcalendar':
                 $arr['html'] = $this->editCalendar();
                 break;
             case 'savecalendar':
                 $arr['html'] = $this->saveCalendar();
                 break;
             case 'deletecalendar':
                 $arr['html'] = $this->deleteCalendar();
                 break;
             case 'refreshcalendar':
                 $arr['html'] = $this->refreshCalendar();
                 break;
             case 'refreshcalendars':
                 $this->refreshCalendars();
                 break;
             case 'eventsources':
                 $this->eventSources();
                 break;
             case 'events':
                 $this->events();
                 break;
             default:
                 $arr['html'] = $this->display();
                 break;
         }
     }
     //get count of all future group events
     $arr['metadata']['count'] = $this->_getAllFutureEvents();
     //get the upcoming events
     $upcoming_events = $this->_getFutureEventsThisMonth();
     if ($upcoming_events > 0) {
         $title = $this->group->get('description') . " has {$upcoming_events} events this month.";
         $link = Route::url('index.php?option=com_groups&cn=' . $this->group->get('cn') . '&active=calendar');
         $arr['metadata']['alert'] = "<a class=\"alrt\" href=\"{$link}\"><span><h5>Calendar Alert</h5>{$title}</span></a>";
     }
     // Return the output
     return $arr;
 }
Example #26
0
 /**
  * Method to save the form data.
  *
  * @param   array  $data  The form data.
  *
  * @return  boolean  True on success.
  *
  * @since   1.6
  */
 public function save($data)
 {
     // Initialise variables;
     $pk = !empty($data['id']) ? $data['id'] : (int) $this->getState('user.id');
     $user = User::getInstance($pk);
     $my = User::getRoot();
     if ($data['block'] && $pk == $my->id && !$my->block) {
         $this->setError(Lang::txt('COM_USERS_USERS_ERROR_CANNOT_BLOCK_SELF'));
         return false;
     }
     // Make sure that we are not removing ourself from Super Admin group
     $iAmSuperAdmin = $my->authorise('core.admin');
     if ($iAmSuperAdmin && $my->get('id') == $pk) {
         // Check that at least one of our new groups is Super Admin
         $stillSuperAdmin = false;
         $myNewGroups = $data['groups'];
         foreach ($myNewGroups as $group) {
             $stillSuperAdmin = $stillSuperAdmin ? $stillSuperAdmin : JAccess::checkGroup($group, 'core.admin');
         }
         if (!$stillSuperAdmin) {
             $this->setError(Lang::txt('COM_USERS_USERS_ERROR_CANNOT_DEMOTE_SELF'));
             return false;
         }
     }
     // Bind the data.
     if (!$user->bind($data)) {
         $this->setError($user->getError());
         return false;
     }
     // Store the data.
     if (!$user->save()) {
         $this->setError($user->getError());
         return false;
     }
     $this->setState('user.id', $user->id);
     return true;
 }
Example #27
0
 /**
  * Method to save the form data.
  *
  * @param	array	$data	The form data.
  *
  * @return	boolean	True on success.
  * @since	1.6
  */
 public function save($data)
 {
     // Initialise variables;
     $user = User::getRoot();
     unset($data['id']);
     unset($data['groups']);
     unset($data['sendEmail']);
     unset($data['block']);
     // Unset the username if it should not be overwritten
     $username = $data['username'];
     $isUsernameCompliant = $this->getState('user.username.compliant');
     if (!Component::params('com_users')->get('change_login_name') && $isUsernameCompliant) {
         unset($data['username']);
     }
     // Bind the data.
     if (!$user->bind($data)) {
         $this->setError($user->getError());
         return false;
     }
     $user->groups = null;
     // Store the data.
     if (!$user->save()) {
         $this->setError($user->getError());
         return false;
     }
     $this->setState('user.id', $user->id);
     return true;
 }
Example #28
0
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 * HUBzero is a registered trademark of Purdue University.
 *
 * @package   hubzero-cms
 * @author    Shawn Rice <zooley@purdue.edu>
 * @copyright Copyright 2005-2015 HUBzero Foundation, LLC.
 * @license   http://opensource.org/licenses/MIT MIT
 */
use Modules\AdminMenu\Node;
defined('_HZEXEC_') or die;
$shownew = (bool) $params->get('shownew', 1);
$user = User::getRoot();
$lang = Lang::getRoot();
//
// Site SubMenu
//
$menu->addChild(new Node(Lang::txt('JSITE'), '#'), true);
$menu->addChild(new Node(Lang::txt('MOD_MENU_CONTROL_PANEL'), 'index.php', 'class:cpanel'));
$menu->addSeparator();
/*
$menu->addChild(
	new Node(Lang::txt('MOD_MENU_USER_PROFILE'), 'index.php?option=com_admin&task=profile.edit&id=' . $user->id, 'class:profile')
);
$menu->addSeparator();
*/
if ($user->authorise('core.admin')) {
    $menu->addChild(new Node(Lang::txt('MOD_MENU_CONFIGURATION'), 'index.php?option=com_config', 'class:config'));
Example #29
0
						(<?php 
                    echo Lang::txt('COM_WISHLIST_PLAN_NOT_STARTED');
                    ?>
)
					<?php 
                }
                ?>
				</h3>
				<form action="<?php 
                echo Route::url('index.php?option=' . $this->option);
                ?>
" method="post" id="planform" enctype="multipart/form-data">
					<p class="plan-member-photo">
						<span class="plan-anchor"></span>
						<img src="<?php 
                echo \Hubzero\User\Profile\Helper::getMemberPhoto(User::getRoot(), 0);
                ?>
" alt="<?php 
                echo Lang::txt('COM_WISHLIST_MEMBER_PICTURE');
                ?>
" />
					</p>
					<fieldset>
				<?php 
                if ($this->wish->get('action') == 'editplan') {
                    ?>
						<div class="grid">
							<div class="col span6">
								<label>
									<?php 
                    echo Lang::txt('COM_WISHLIST_WISH_ASSIGNED_TO');
Example #30
0
 /**
  *  Constructor
  *
  * @param   mixes   $raw      Raw data
  * @param   array   $options  Import options
  * @param   string  $mode     Operation mode (update|patch)
  * @return  void
  */
 public function __construct($raw, $options = array(), $mode = 'UPDATE')
 {
     // Store our incoming data
     $this->raw = $raw;
     $this->_options = $options;
     $this->_mode = strtoupper($mode);
     // Create core objects
     $this->_database = \App::get('db');
     $this->_user = \User::getRoot();
     // Create objects
     $this->record = new stdClass();
     // Message bags for user
     $this->record->errors = array();
     $this->record->notices = array();
     // Bind data
     $this->bind();
 }