/** * Save changes to the registration * * @return void */ public function saveTask() { // Check for request forgeries Request::checkToken(); $settings = Request::getVar('settings', array(), 'post'); if (!is_array($settings) || empty($settings)) { App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_MEMBERS_REGISTRATION_ERROR_MISSING_DATA'), 'error'); return; } $arr = array(); $component = new \JTableExtension($this->database); $component->load($component->find(array('element' => $this->_option, 'type' => 'component'))); $params = new \Hubzero\Config\Registry($component->params); foreach ($settings as $name => $value) { $r = $value['create'] . $value['proxy'] . $value['update'] . $value['edit']; $params->set('registration' . trim($name), trim($r)); } $component->params = $params->toString(); $component->store(); if (App::get('config')->get('caching')) { $handler = App::get('config')->get('cache_handler'); App::get('config')->set($handler, array('cachebase' => PATH_APP . '/cache/site')); $cache = new \Hubzero\Cache\Manager(\App::getRoot()); $cache->storage($handler); $cache->clean('_system'); } App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_MEMBERS_REGISTRATION_SAVED')); }
/** * Down **/ public function down() { $this->addPluginEntry('resources', 'abouttool'); if ($this->db->tableExists('#__resource_types')) { // Get all the "mine" queries $this->db->setQuery("SELECT id, params FROM `#__resource_types` WHERE `category`=27 AND `alias`='tools'"); if ($records = $this->db->loadObjectList()) { $path = PATH_CORE . DS . 'components' . DS . 'com_resources' . DS . 'tables' . DS . 'type.php'; if (!file_exists($path)) { $path = PATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_resources' . DS . 'tables' . DS . 'type.php'; } include_once $path; $tbl = '\\Components\\Resources\\Tables\\Type'; if (class_exists('ResourcesType')) { $tbl = 'ResourcesType'; } // Update the query foreach ($records as $record) { $row = new $tbl($this->db); $row->bind($record); $p = new \Hubzero\Config\Registry($row->params); $p->set('plg_about', 0); $p->set('plg_abouttool', 1); $row->params = $p->toString(); $row->store(); } } } }
/** * Up **/ public function up() { if ($this->db->tableExists('#__extensions')) { $query = "SELECT * FROM `#__extensions` WHERE `element` IN ('com_users', 'com_members')"; $this->db->setQuery($query); $objs = $this->db->loadObjectList(); $users = null; $members = null; foreach ($objs as $obj) { if ($obj->element == 'com_users') { $users = new \Hubzero\Config\Registry($obj->params); } if ($obj->element == 'com_members') { $members = new \Hubzero\Config\Registry($obj->params); } } if ($users && $members) { $params = array('allowUserRegistration' => 1, 'new_usertype' => 2, 'guest_usergroup' => 1, 'sendpassword' => 1, 'useractivation' => 2, 'simple_registration' => 0, 'allow_duplicate_emails' => 0, 'mail_to_admin' => 1, 'captcha' => '', 'frontend_userparams' => 1, 'site_language' => 0, 'change_login_name' => 0, 'reset_count' => 10, 'reset_time' => 1, 'login_attempts_limit' => 10, 'login_attempts_timeframe' => 1); foreach ($params as $param => $dflt) { $members->set($param, $users->get('param', $dflt)); } $query = "UPDATE `#__extensions` SET `params`=" . $this->db->quote($members->toString()) . " WHERE `element`='com_members'"; $this->db->setQuery($query); $this->db->query(); } } }
/** * Up **/ public function up() { $query = "CREATE TABLE IF NOT EXISTS `#__announcements` (\n\t\t\t\t\t`id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t`scope` varchar(100) DEFAULT NULL,\n\t\t\t\t\t`scope_id` int(11) DEFAULT NULL,\n\t\t\t\t\t`content` text,\n\t\t\t\t\t`priority` tinyint(2) NOT NULL DEFAULT '0',\n\t\t\t\t\t`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',\n\t\t\t\t\t`created_by` int(11) NOT NULL DEFAULT '0',\n\t\t\t\t\t`state` tinyint(2) NOT NULL DEFAULT '0',\n\t\t\t\t\t`publish_up` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',\n\t\t\t\t\t`publish_down` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',\n\t\t\t\t\t`sticky` tinyint(2) NOT NULL DEFAULT '0',\n\t\t\t\t\tPRIMARY KEY (`id`)\n\t\t\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8;"; $this->db->setQuery($query); $this->db->query(); $params = array('plugin_access' => 'members', 'display_tab' => 1); $this->addPluginEntry('groups', 'announcements', 1, $params); // get citation params if ($this->db->tableExists('#__extensions')) { $sql = "SELECT `params` FROM `#__extensions` WHERE `type`='plugin' AND `element`='messages' AND `folder` = 'groups'"; } else { $sql = "SELECT `params` FROM `#__plugins` WHERE `element`='messages' AND `folder`='groups'"; } $this->db->setQuery($sql); $p = $this->db->loadResult(); // load params object $params = new \Hubzero\Config\Registry($p); // set param to hide messages tab $params->set('display_tab', 0); // save new params if ($this->db->tableExists('#__extensions')) { $query = "UPDATE `#__extensions` SET `params`=" . $this->db->quote(json_encode($params->toArray())) . " WHERE `element`='messages' AND `folder`='groups'"; } else { $query = "UPDATE `#__plugins` SET `params`='" . $params->toString() . "' WHERE `element`='messages' AND `folder`='groups'"; } $this->db->setQuery($query); $this->db->query(); }
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); }
/** * Up **/ public function up() { if ($this->db->tableExists('#__extensions')) { $query = "SELECT * FROM `#__extensions` WHERE `type`='plugin' AND `folder`='system' AND `element`='jquery' LIMIT 1;"; $this->db->setQuery($query); if ($plugin = $this->db->loadObject()) { $params = new \Hubzero\Config\Registry($plugin->params); $params->set('jquery', 1); $params->set('jqueryui', 1); $params->set('jqueryfb', 1); $params->set('activateAdmin', 0); $params->set('noconflictAdmin', 0); $params->set('activateSite', 1); $params->set('noconflictSite', 0); $query = "UPDATE `#__extensions` SET `params`=" . $this->db->quote($params->toString()) . " WHERE `extension_id`=" . $this->db->quote($plugin->extension_id); $this->db->setQuery($query); $this->db->query(); } $query = "SELECT * FROM `#__extensions` WHERE `type`='plugin' AND `folder`='content' AND `element`='formatwiki' LIMIT 1;"; $this->db->setQuery($query); if ($plugin = $this->db->loadObject()) { $params = new \Hubzero\Config\Registry($plugin->params); $params->set('applyFormat', 1); $params->set('convertFormat', 1); $query = "UPDATE `#__extensions` SET `params`=" . $this->db->quote($params->toString()) . " WHERE `extension_id`=" . $this->db->quote($plugin->extension_id); $this->db->setQuery($query); $this->db->query(); } $query = "SELECT * FROM `#__extensions` WHERE `type`='plugin' AND `folder`='content' AND `element`='formathtml' LIMIT 1;"; $this->db->setQuery($query); if ($plugin = $this->db->loadObject()) { $params = new \Hubzero\Config\Registry($plugin->params); $params->set('applyFormat', 1); $params->set('convertFormat', 0); $params->set('sanitizeBefore', 0); $query = "UPDATE `#__extensions` SET `params`=" . $this->db->quote($params->toString()) . " WHERE `extension_id`=" . $this->db->quote($plugin->extension_id); $this->db->setQuery($query); $this->db->query(); if (!$plugin->enabled) { $this->enablePlugin('content', 'formathtml'); } } else { $params = new \Hubzero\Config\Registry(); $params->set('applyFormat', 1); $params->set('convertFormat', 0); $params->set('sanitizeBefore', 0); $this->addPluginEntry('content', 'formathtml', 1, $params->toString()); } } }
function display($tpl = null) { // Assign variables to the view $authenticator = \Request::getWord('authenticator', false); \Hubzero\Document\Assets::addComponentStylesheet('com_user', 'login.css'); // Get the site name $sitename = \Config::get('sitename'); // Get the display name for the current plugin being used $plugin = Plugin::byType('authentication', $authenticator); $pparams = new \Hubzero\Config\Registry($plugin->params); $display_name = $pparams->get('display_name', ucfirst($plugin->name)); $this->assign('authenticator', $authenticator); $this->assign('sitename', $sitename); $this->assign('display_name', $display_name); parent::display($tpl); }
/** * Down **/ public function down() { $this->addComponentEntry('register'); $rparams = $this->getParams('com_members'); $values = $rparams->toArray(); $this->db->setQuery("SELECT * FROM `#__extensions` WHERE `type`='component' AND `element`='com_register' LIMIT 1"); if ($data = $this->db->loadAssoc()) { $component = new \JTableExtension($this->db); $component->bind($data); $mparams = new \Hubzero\Config\Registry($component->params); foreach ($values as $key => $value) { $mparams->set($key, $value); } $component->params = $mparams->toString(); $component->store(); } }
/** * Utility method to act on a user after it has been saved. * * This method sends a registration email to new users created in the backend. * * @param array $user Holds the new user data. * @param boolean $isnew True if a new user is stored. * @param boolean $success True if user was succesfully stored in the database. * @param string $msg Message. * @return void */ public function onUserAfterSave($user, $isnew, $success, $msg) { // Initialise variables. $config = App::get('config'); $mail_to_user = $this->params->get('mail_to_user', 0); // [!] HUBzero - changed default value if ($isnew) { // TODO: Suck in the frontend registration emails here as well. Job for a rainy day. if (App::isAdmin()) { if ($mail_to_user) { $lang = App::get('language'); $defaultLocale = $lang->getTag(); // Look for user language. Priority: // 1. User frontend language // 2. User backend language $userParams = new \Hubzero\Config\Registry($user['params']); $userLocale = $userParams->get('language', $userParams->get('admin_language', $defaultLocale)); if ($userLocale != $defaultLocale) { $lang->setLanguage($userLocale); } $lang->load('plg_user_joomla', PATH_APP . DS . 'bootstrap' . DS . 'site') || $lang->load('plg_user_joomla', PATH_APP . DS . 'bootstrap' . DS . 'administrator') || $lang->load('plg_user_joomla', __DIR__); // Compute the mail subject. $emailSubject = Lang::txt('PLG_USER_JOOMLA_NEW_USER_EMAIL_SUBJECT', $user['name'], $config->get('sitename')); // Compute the mail body. $emailBody = Lang::txt('PLG_USER_JOOMLA_NEW_USER_EMAIL_BODY', $user['name'], $config->get('sitename'), Request::root(), $user['username'], $user['password_clear']); // Assemble the email data...the sexy way! $mail = JFactory::getMailer()->setSender(array($config->get('mailfrom'), $config->get('fromname')))->addRecipient($user['email'])->setSubject($emailSubject)->setBody($emailBody); // Set application language back to default if we changed it if ($userLocale != $defaultLocale) { $lang->setLanguage($defaultLocale); } if (!$mail->Send()) { // TODO: Probably should raise a plugin error but this event is not error checked. throw new Exception(Lang::txt('ERROR_SENDING_EMAIL'), 500); } } } } else { // Existing user - nothing to do...yet. } }
/** * Return data on a course view (this will be some form of HTML) * * @param object $course Current course * @param object $offering Name of the component * @param boolean $describe Return plugin description only? * @return object */ public function onCourse($course, $offering, $describe = false) { $response = with(new \Hubzero\Base\Object())->set('name', $this->_name)->set('title', Lang::txt('PLG_COURSES_' . strtoupper($this->_name)))->set('description', JText::_('PLG_COURSES_' . strtoupper($this->_name) . '_BLURB'))->set('default_access', $this->params->get('plugin_access', 'members'))->set('display_menu_tab', true)->set('icon', 'f0ae'); if ($describe) { return $response; } if (!($active = Request::getVar('active'))) { Request::setVar('active', $active = $this->_name); } // Check to see if user is member and plugin access requires members $sparams = new \Hubzero\Config\Registry($course->offering()->section()->get('params')); if (!$course->offering()->section()->access('view') && !$sparams->get('preview', 0)) { $response->set('html', '<p class="info">' . Lang::txt('COURSES_PLUGIN_REQUIRES_MEMBER', ucfirst($active)) . '</p>'); return $response; } // Determine if we need to return any HTML (meaning this is the active plugin) if ($response->get('name') == $active) { $this->css(); // Course and action $this->course = $course; $action = strtolower(Request::getWord('action', '')); $this->view = $this->view('default', 'outline'); $this->view->option = Request::getCmd('option', 'com_courses'); $this->view->controller = Request::getWord('controller', 'course'); $this->view->course = $course; $this->view->offering = $offering; $this->view->config = $course->config(); switch ($action) { case 'build': $this->_build(); break; default: $this->js(); $this->_display(); break; } $response->set('html', $this->view->loadTemplate()); } // Return the output return $response; }
/** * Up **/ public function up() { if ($this->db->tableExists('#__extensions')) { $query = "SELECT * FROM `#__extensions` WHERE `element`=" . $this->db->quote('novnc') . " AND `folder`=" . $this->db->quote('tools'); $this->db->setQuery($query); $result = $this->db->loadObject(); if ($result && $result->extension_id) { $params = new \Hubzero\Config\Registry($result->params); $params->set('browsers', '*, safari 5.1 *, chrome 26.0 *, iceweasel 38.0 *, firefox 30.0 *, opera 23.0 *, mozilla 5.0 iOS, safari 1.0 Windows, msie 10.0 Windows, ie 10.0'); $query = "UPDATE `#__extensions` SET `params`=" . $this->db->quote($params->toString()) . " WHERE `extension_id`=" . $this->db->quote($result->extension_id); $this->db->setQuery($query); $this->db->query(); } $query = "SELECT * FROM `#__extensions` WHERE `element`=" . $this->db->quote('java') . " AND `folder`=" . $this->db->quote('tools'); $this->db->setQuery($query); $result = $this->db->loadObject(); if ($result && $result->extension_id) { $params = new \Hubzero\Config\Registry($result->params); $params->set('browsers', '*, chrome 999999.0 *, safari 1.0 *, iceweasel 1.0 *, firefox 1.0 *, opera 1.0 *, IE 3.0 *, mozilla 5.0 iOS, Safari 9999.9'); $query = "UPDATE `#__extensions` SET `params`=" . $this->db->quote($params->toString()) . " WHERE `extension_id`=" . $this->db->quote($result->extension_id); $this->db->setQuery($query); $this->db->query(); } } }
/** * Up **/ public function up() { //create new format table $query = "CREATE TABLE IF NOT EXISTS `#__citations_format` (\n\t\t\t\t\t`id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t`typeid` int(11) DEFAULT NULL,\n\t\t\t\t\t`style` varchar(50) DEFAULT NULL,\n\t\t\t\t\t`format` text,\n\t\t\t\t\tPRIMARY KEY (`id`)\n\t\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8;"; $this->db->setQuery($query); $this->db->query(); // get citation params if ($this->db->tableExists('#__extensions')) { $sql = "SELECT params FROM `#__extensions` WHERE `type`='component' AND `element`='com_citations';"; } else { $sql = "SELECT params FROM `#__components` WHERE `option`='com_citations';"; } $this->db->setQuery($sql); $rawCitationParams = $this->db->loadResult(); $citationParams = new \Hubzero\Config\Registry($rawCitationParams); //insert default format $query = "INSERT INTO `#__citations_format` (`typeid`, `style`, `format`)\n\t\t\tSELECT NULL,'custom'," . $this->db->quote($citationParams->get('citation_format', '')) . "\n\t\t\tFROM DUAL WHERE NOT EXISTS (SELECT `typeid` FROM `#__citations_format` WHERE `typeid` IS NULL);"; if (!empty($query)) { $this->db->setQuery($query); $this->db->query(); } }
/** * redefine the function an add some properties to make the styling more easy * * @return mixed An array of data items on success, false on failure. */ public function getItems() { if (!count($this->_items)) { $app = JFactory::getApplication(); $menu = \App::get('menu'); $active = $menu->getActive(); $params = new \Hubzero\Config\Registry(); if ($active) { $params->parse($active->params); } $options = array(); $options['countItems'] = $params->get('show_cat_items_cat', 1) || !$params->get('show_empty_categories_cat', 0); $categories = JCategories::getInstance('Newsfeeds', $options); $this->_parent = $categories->get($this->getState('filter.parentId', 'root')); if (is_object($this->_parent)) { $this->_items = $this->_parent->getChildren(); } else { $this->_items = false; } } return $this->_items; }
/** * Save an entry * * @return void */ public function saveTask() { // Check for request forgeries Request::checkToken(); $fields = Request::getVar('fields', array(), 'post'); $row = Role::oneOrNew(intval($fields['id']))->set($fields); if (!isset($fields['permissions'])) { $fields['permissions'] = array(); } $permissions = new \Hubzero\Config\Registry($fields['permissions']); $row->set('permissions', $permissions->toString()); // Store new content if (!$row->save()) { Notify::error($row->getError()); return $this->editTask($row); } Notify::success(Lang::txt('COM_GROUPS_ROLE_SAVED')); // Redirect to main listing if ($this->getTask() == 'apply') { return $this->editTask($row); } $this->cancelTask(); }
/** * Get params of owners connected to external service * * @param integer $projectid * @param string $service * @param array $exclude * * @return object */ public function getConnected($projectid = NULL, $service = 'google', $exclude = array()) { if ($projectid === NULL) { return false; } $query = "SELECT o.* FROM {$this->_tbl} AS o "; $query .= " JOIN #__projects as p ON o.projectid=p.id"; $query .= " WHERE o.userid > 0"; $query .= " AND p.id=" . $this->_db->quote($projectid); $query .= " AND o.params LIKE '%google_token=%' AND o.params NOT LIKE '%google_token=\n%'"; if (!empty($exclude)) { $query .= " AND o.userid NOT IN ("; $k = 1; foreach ($exclude as $ex) { $query .= $ex; $query .= $k < count($exclude) ? ',' : ''; $k++; } $query .= ")"; } $this->_db->setQuery($query); $results = $this->_db->loadObjectList(); $connected = array(); foreach ($results as $result) { $params = new \Hubzero\Config\Registry($result->params); $name = utf8_decode($params->get($service . '_name', '')); $email = $params->get($service . '_email', ''); if ($name && $email) { $connected[$name] = $email; } } return $connected; }
/** * Get a list of events for a group * * @param object $group * @param array $filters * @return array */ private function getGroupMembers($group, $filters = array()) { // get members from group $members = $group->get('members'); // get group params $params = \Component::params("com_groups"); $displaySystemUsers = $params->get('display_system_users', 'no'); //get this groups params $gparams = new \Hubzero\Config\Registry($group->get('params')); $displaySystemUsers = $gparams->get('display_system_users', $displaySystemUsers); // filter is system users if ($displaySystemUsers == 'no') { $members = array_map(function ($userid) { return $userid < 1000 ? null : $userid; }, $members); $members = array_values(array_filter($members)); } // shuffle order shuffle($members); // limit members based on the filter $members = array_slice($members, 0, $filters['limit']); //return members return $members; }
break; case "breeze": $breeze .= !$breeze ? '<a title="View Presentation - Flash Version" class="breeze flash" href="' . $grandchild->path . '&no_html=1" title="' . $this->escape(stripslashes($grandchild->title)) . '">' . Lang::txt('View Flash') . '</a>' : ''; break; case "hubpresenter": $hubpresenter .= !$hubpresenter ? '<a title="View Presentation - HTML5 Version" class="hubpresenter html5" href="' . $grandchild->path . '" title="' . $this->escape(stripslashes($grandchild->title)) . '">' . Lang::txt('View HTML') . '</a>' : ''; break; case "pdf": default: if ($grandchild->logicaltype == 14) { $pdf .= '<a href="' . $grandchild->path . '">' . Lang::txt('Notes') . '</a>' . "\n"; } elseif ($grandchild->logicaltype == 51) { $exercises .= '<a href="' . $grandchild->path . '">' . stripslashes($grandchild->title) . '</a>' . "\n"; } else { $grandchildParams = new \Hubzero\Config\Registry($grandchild->params); $grandchildAttribs = new \Hubzero\Config\Registry($grandchild->attribs); $linkAction = $grandchildParams->get('link_action', 0); $width = $grandchildAttribs->get('width', 640) + 20; $height = $grandchildAttribs->get('height', 360) + 60; if ($linkAction == 1) { $supp .= '<a rel="external" href="' . $grandchild->path . '">' . stripslashes($grandchild->title) . '</a><br />' . "\n"; } elseif ($linkAction == 2) { $url = Route::url('index.php?option=com_resources&id=' . $child->id . '&resid=' . $grandchild->id . '&task=play'); $supp .= '<a class="play ' . $width . 'x' . $height . '" href="' . $url . '">' . stripslashes($grandchild->title) . '</a><br />' . "\n"; } else { $supp .= '<a href="' . $grandchild->path . '">' . stripslashes($grandchild->title) . '</a><br />' . "\n"; } } break; } }
/** * Method to get a single record. * * @param integer The id of the primary key. * * @return mixed Object on success, false on failure. */ public function getItem($pk = null) { // Initialise variables. $pk = !empty($pk) ? $pk : (int) $this->getState('style.id'); if (!isset($this->_cache[$pk])) { $false = false; // Get a row instance. $table = $this->getTable(); // Attempt to load the row. $return = $table->load($pk); // Check for a table object error. if ($return === false && $table->getError()) { $this->setError($table->getError()); return $false; } // Convert to the Object before adding other data. $properties = $table->getProperties(1); $this->_cache[$pk] = \Hubzero\Utility\Arr::toObject($properties, '\\Hubzero\\Base\\Object'); // Convert the params field to an array. $registry = new \Hubzero\Config\Registry($table->params); $this->_cache[$pk]->params = $registry->toArray(); // Get the template XML. //$client = \Hubzero\Base\ClientManager::client($table->client_id); $patha = Filesystem::cleanPath(PATH_APP . '/templates/' . $table->template . '/templateDetails.xml'); $pathc = Filesystem::cleanPath(PATH_CORE . '/templates/' . $table->template . '/templateDetails.xml'); if (file_exists($patha)) { $this->_cache[$pk]->xml = simplexml_load_file($patha); } elseif (file_exists($pathc)) { $this->_cache[$pk]->xml = simplexml_load_file($pathc); } else { $this->_cache[$pk]->xml = null; } } return $this->_cache[$pk]; }
/** * Actions to perform after deleting a course * * @param object $model \Components\Courses\Models\Course * @return void */ public function onOfferingDelete($model) { if (!$model->exists()) { return; } $params = new \Hubzero\Config\Registry($model->get('params')); if ($product = $params->get('store_product_id', 0)) { $warehouse = new StorefrontModelWarehouse(); // Delete by existing course ID (pID returned with $course->add() when the course was created) $warehouse->deleteProduct($product); } }
/** * Map Resource Data * * @return void */ private function _mapResourceData() { // do we want to do a title match? if ($this->_options['titlematch'] == 1 && isset($this->record->type->id)) { $sql = 'SELECT id, title, LEVENSHTEIN( title, ' . $this->_database->quote($this->raw->title) . ' ) as titleDiff FROM `#__resources` WHERE `type`=' . $this->record->type->id . ' HAVING titleDiff < ' . self::TITLE_MATCH; $this->_database->setQuery($sql); $results = $this->_database->loadObjectList('id'); // did we get more then one result? if (count($results) > 1) { $ids = implode(", ", array_keys($results)); throw new Exception(Lang::txt('COM_RESOURCES_IMPORT_RECORD_MODEL_UNABLE_DETECTDUPLICATE', $ids)); } // if we only have one were all good if (count($results) == 1) { // set our id to the matched resource $resource = reset($results); $this->raw->id = $resource->id; // add a notice with link to resource matched $resourceLink = rtrim(str_replace('administrator', '', \Request::base()), DS) . DS . 'resources' . DS . $resource->id; $link = '<a target="_blank" href="' . $resourceLink . '">' . $resourceLink . '</a>'; array_push($this->record->notices, Lang::txt('COM_RESOURCES_IMPORT_RECORD_MODEL_MATCHEDBYTITLE', $link)); } } // do we have a resource id // either passed in the raw data or gotten from the title match if (isset($this->raw->id) && $this->raw->id > 1) { $this->record->resource->load($this->raw->id); } else { $this->raw->standalone = 1; $this->raw->created = \Date::toSql(); $this->raw->created_by = $this->_user->get('id'); // publish up/down if (!isset($this->raw->publish_up)) { $this->raw->publish_up = \Date::toSql(); } if (!isset($this->raw->publish_down)) { $this->raw->publish_down = '0000-00-00 00:00:00'; } } // set modified date/user $this->raw->modified = \Date::toSql(); $this->raw->modified_by = $this->_user->get('id'); // set status if (isset($this->_options['status'])) { $this->raw->published = (int) $this->_options['status']; } // set group if (isset($this->_options['group'])) { $this->raw->group_owner = $this->_options['group']; } // set access if (isset($this->_options['access'])) { $this->raw->access = (int) $this->_options['access']; } // bind resource data $this->record->resource->bind($this->raw); // resource params $params = new \Hubzero\Config\Registry($this->record->resource->params); $this->record->resource->params = $params->toString(); // resource attributes $attribs = new \Hubzero\Config\Registry($this->record->resource->attribs); $this->record->resource->attribs = $attribs->toString(); // full text pieces - to add paragraph tags $fullTextPieces = array_map("trim", explode("\n", $this->record->resource->introtext)); $fullTextPieces = array_values(array_filter($fullTextPieces)); // set the full text $this->record->resource->fulltxt = "<p>" . implode("</p>\n<p>", $fullTextPieces) . "</p>"; if (!isset($this->raw->custom_fields)) { $this->raw->custom_fields = array(); } // bind custom fields to types custom fields if (isset($this->record->type->id)) { $resourcesElements = new \Components\Resources\Models\Elements((array) $this->raw->custom_fields, $this->record->type->customFields); $customFieldsHtml = $resourcesElements->toDatabaseHtml(); // add all custom fields to custom object foreach ($resourcesElements->getSchema()->fields as $field) { $fieldLabel = $field->label; $fieldName = $field->name; $value = isset($this->raw->custom_fields->{$fieldName}) ? $this->raw->custom_fields->{$fieldName} : null; if ($field->type == 'hidden') { $value = isset($field->options[0]) ? $field->options[0]->value : $value; } $this->record->custom->{$fieldLabel} = $value; } } else { $customFieldsHtml = ''; } // add custom fields to fulltxt $this->record->resource->fulltxt .= "\n\n" . $customFieldsHtml; }
/** * Method is called after user data is stored in the database * * @param array $user holds the new user data * @param boolean $isnew true if a new user is stored * @param boolean $success true if user was succesfully stored in the database * @param string $msg message * @return void */ public function onAfterStoreUser($user, $isnew, $succes, $msg) { $xprofile = \Hubzero\User\Profile::getInstance($user['id']); if (!is_object($xprofile)) { $params = Component::params('com_members'); $hubHomeDir = rtrim($params->get('homedir'), '/'); if (empty($hubHomeDir)) { // try to deduce a viable home directory based on sitename or live_site $sitename = strtolower(Config::get('sitename')); $sitename = preg_replace('/^http[s]{0,1}:\\/\\//', '', $sitename, 1); $sitename = trim($sitename, '/ '); $sitename_e = explode('.', $sitename, 2); if (isset($sitename_e[1])) { $sitename = $sitename_e[0]; } if (!preg_match("/^[a-zA-Z]+[\\-_0-9a-zA-Z\\.]+\$/i", $sitename)) { $sitename = ''; } if (empty($sitename)) { $sitename = strtolower(Request::base()); $sitename = preg_replace('/^http[s]{0,1}:\\/\\//', '', $sitename, 1); $sitename = trim($sitename, '/ '); $sitename_e = explode('.', $sitename, 2); if (isset($sitename_e[1])) { $sitename = $sitename_e[0]; } if (!preg_match("/^[a-zA-Z]+[\\-_0-9a-zA-Z\\.]+\$/i", $sitename)) { $sitename = ''; } } $hubHomeDir = DS . 'home'; if (!empty($sitename)) { $hubHomeDir .= DS . $sitename; } if (!empty($hubHomeDir)) { $db = App::get('db'); $component = new JTableExtension($this->database); $component->load($component->find(array('element' => 'com_members', 'type' => 'component'))); $params = new \Hubzero\Config\Registry($component->params); $params->set('homedir', $hubHomeDir); $component->params = $params->toString(); $component->store(); } } $xprofile = new \Hubzero\User\Profile(); $xprofile->set('gidNumber', $params->get('gidNumber', '100')); $xprofile->set('gid', $params->get('gid', 'users')); $xprofile->set('uidNumber', $user['id']); $xprofile->set('homeDirectory', $hubHomeDir . DS . $user['username']); $xprofile->set('loginShell', '/bin/bash'); $xprofile->set('ftpShell', '/usr/lib/sftp-server'); $xprofile->set('name', $user['name']); $xprofile->set('email', $user['email']); $xprofile->set('emailConfirmed', '3'); $xprofile->set('username', $user['username']); $xprofile->set('regIP', $_SERVER['REMOTE_ADDR']); $xprofile->set('emailConfirmed', -rand(1, pow(2, 31) - 1)); $xprofile->set('public', $params->get('privacy', 0)); if (isset($_SERVER['REMOTE_HOST'])) { $xprofile->set('regHost', $_SERVER['REMOTE_HOST']); } $xprofile->set('registerDate', Date::toSql()); $result = $xprofile->create(); if (!$result) { return new Exception('Unable to create \\Hubzero\\User\\Profile record', 500); } } else { $update = false; $params = Component::params('com_members'); if ($xprofile->get('username') != $user['username']) { $xprofile->set('username', $user['username']); $update = true; } if ($xprofile->get('name') != $user['name']) { $xprofile->set('name', $user['name']); $update = true; } if ($xprofile->get('email') != $user['email']) { $xprofile->set('email', $user['email']); $xprofile->set('emailConfirmed', 0); $update = true; } if ($xprofile->get('emailConfirmed') == '') { $xprofile->set('emailConfirmed', '3'); $update = true; } if ($xprofile->get('gid') == '') { $xprofile->set('gid', $params->get('gid', 'users')); $update = true; } if ($xprofile->get('gidNumber') == '') { $xprofile->set('gidNumber', $params->get('gidNumber', '100')); $update = true; } if ($xprofile->get('loginShell') == '') { $xprofile->set('loginShell', '/bin/bash'); $update = true; } if ($xprofile->get('ftpShell') == '') { $xprofile->set('ftpShell', '/usr/lib/sftp-server'); // This isn't right, but we're using an empty shell as an indicator that we should also update default privacy $xprofile->set('public', $params->get('privacy', 0)); $update = true; } if ($update) { $xprofile->update(); } } // 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' => $user['id'])); if (!$quota->id) { $class = new \Components\Members\Tables\QuotasClasses($this->database); $class->load(array('alias' => 'default')); if ($class->id) { $quota->set('user_id', $user['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(); } } } }
* 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 Christopher Smoak <*****@*****.**> * @copyright Copyright 2005-2015 HUBzero Foundation, LLC. * @license http://opensource.org/licenses/MIT MIT */ // No direct access defined('_HZEXEC_') or die; // get group params $params = new \Hubzero\Config\Registry($this->group->get('params')); //is membership control managed on group? $membership_control = $params->get('membership_control', 1); // build urls $currentUrl = Request::current(true); $groupUrl = 'index.php?option=com_groups&cn=' . $this->group->get('cn'); // build login and logout links $loginReturn = base64_encode($currentUrl); $logoutReturn = base64_encode(Route::url($groupUrl)); $loginLink = Route::url('index.php?option=com_users&view=login&return=' . $loginReturn); $logoutLink = Route::url('index.php?option=com_users&view=logout&return=' . $logoutReturn); // super group login link if ($this->group->isSuperGroup()) { $loginLink = Route::url($groupUrl . '&active=login&return=' . base64_encode(Route::url($currentUrl))); } ?>
/** * Special formatting for results * * @param object $row Database row * @param string $period Time period * @return string */ public static function out($row, $period) { $database = App::get('db'); $helper = new \Components\Resources\Helpers\Helper($row->id, $database); // Instantiate a helper object if (!isset($row->authors)) { $helper->getContributors(); $row->authors = $helper->contributors; } // Get the component params and merge with resource params $config = Component::params('com_resources'); $rparams = new \Hubzero\Config\Registry($row->params); // Set the display date switch ($rparams->get('show_date', $config->get('show_date'))) { case 0: $thedate = ''; break; case 1: $thedate = Date::of($row->created)->toLocal(Lang::txt('DATE_FORMAT_HZ1')); break; case 2: $thedate = Date::of($row->modified)->toLocal(Lang::txt('DATE_FORMAT_HZ1')); break; case 3: $thedate = Date::of($row->publish_up)->toLocal(Lang::txt('DATE_FORMAT_HZ1')); break; } // Start building HTML $html = "\t" . '<li class="resource">' . "\n"; $html .= "\t\t" . '<p class="title"><a href="' . $row->href . '">' . stripslashes($row->title) . '</a></p>' . "\n"; if ($rparams->get('show_ranking', $config->get('show_ranking'))) { $helper->getCitationsCount(); $helper->getLastCitationDate(); if ($row->area == 'Tools') { $stats = new \Components\Resources\Helpers\Usage\Stats($database, $row->id, $row->category, $row->rating, $helper->citationsCount, $helper->lastCitationDate); } else { $stats = new \Components\Resources\Helpers\Usage\Andmore($database, $row->id, $row->category, $row->rating, $helper->citationsCount, $helper->lastCitationDate); } $statshtml = $stats->display(); $row->ranking = round($row->ranking, 1); $html .= "\t\t" . '<div class="metadata">' . "\n"; $r = 10 * $row->ranking; if (intval($r) < 10) { $r = '0' . $r; } $html .= "\t\t\t" . '<dl class="rankinfo">' . "\n"; $html .= "\t\t\t\t" . '<dt class="ranking"><span class="rank-' . $r . '">' . Lang::txt('PLG_WHATSNEW_RESOURCES_THIS_HAS') . '</span> ' . number_format($row->ranking, 1) . ' ' . Lang::txt('PLG_WHATSNEW_RESOURCES_RANKING') . '</dt>' . "\n"; $html .= "\t\t\t\t" . '<dd>' . "\n"; $html .= "\t\t\t\t\t" . '<p>' . Lang::txt('PLG_WHATSNEW_RESOURCES_RANKING_EXPLANATION') . '</p>' . "\n"; $html .= "\t\t\t\t\t" . '<div>' . "\n"; $html .= $statshtml; $html .= "\t\t\t\t\t" . '</div>' . "\n"; $html .= "\t\t\t\t" . '</dd>' . "\n"; $html .= "\t\t\t" . '</dl>' . "\n"; $html .= "\t\t" . '</div>' . "\n"; } elseif ($rparams->get('show_rating', $config->get('show_rating'))) { switch ($row->rating) { case 0.5: $class = ' half-stars'; break; case 1: $class = ' one-stars'; break; case 1.5: $class = ' onehalf-stars'; break; case 2: $class = ' two-stars'; break; case 2.5: $class = ' twohalf-stars'; break; case 3: $class = ' three-stars'; break; case 3.5: $class = ' threehalf-stars'; break; case 4: $class = ' four-stars'; break; case 4.5: $class = ' fourhalf-stars'; break; case 5: $class = ' five-stars'; break; case 0: default: $class = ' no-stars'; break; } $html .= "\t\t" . '<div class="metadata">' . "\n"; $html .= "\t\t\t" . '<p class="rating"><span class="avgrating' . $class . '"><span>' . Lang::txt('PLG_WHATSNEW_RESOURCES_OUT_OF_5_STARS', $row->rating) . '</span> </span></p>' . "\n"; $html .= "\t\t" . '</div>' . "\n"; } $html .= "\t\t" . '<p class="details">' . $thedate . ' <span>|</span> ' . $row->area; if ($row->authors) { $html .= ' <span>|</span> ' . Lang::txt('PLG_WHATSNEW_RESOURCES_CONTRIBUTORS') . ' ' . $row->authors; } $html .= '</p>' . "\n"; if ($row->itext) { $html .= "\t\t" . '<p>' . \Hubzero\Utility\String::truncate(strip_tags(stripslashes($row->itext)), 200) . '</p>' . "\n"; } else { if ($row->ftext) { $html .= "\t\t" . '<p>' . \Hubzero\Utility\String::truncate(strip_tags(stripslashes($row->ftext)), 200) . '</p>' . "\n"; } } $html .= "\t\t" . '<p class="href">' . Request::base() . trim($row->href, '/') . '</p>' . "\n"; $html .= "\t" . '</li>' . "\n"; // Return output return $html; }
/** * Short description for 'buildToolStatus' * * Long description (if any) ... * * @param array $toolinfo Parameter description (if any) ... * @param array $developers Parameter description (if any) ... * @param array $authors Parameter description (if any) ... * @param array $version Parameter description (if any) ... * @param array &$status Parameter description (if any) ... * @param unknown $option Parameter description (if any) ... * @return array Return description (if any) ... */ public function buildToolStatus($toolinfo, $developers = array(), $authors = array(), $version, &$status, $option) { // Create a Version object $objV = new Version($this->_db); // Get the component parameters $this->config = Component::params($option); $invokedir = $this->config->get('invokescript_dir', DS . 'apps'); $dev_suffix = $this->config->get('dev_suffix', '_dev'); $vnc = $this->config->get('default_vnc', '780x600'); $mw = $this->config->get('default_mw', 'narwhal'); $hostreq = $this->config->get('default_hostreq', 'sessions'); // Load version params $params = new \Hubzero\Config\Registry($version[0]->params); // build status array $status = array('resourceid' => isset($toolinfo[0]->rid) ? $toolinfo[0]->rid : 0, 'resource_created' => isset($toolinfo[0]->rcreated) ? $toolinfo[0]->rcreated : '', 'resource_modified' => isset($toolinfo[0]) && isset($toolinfo[0]->rmodified) && $toolinfo[0]->rmodified != '0000-00-00 00:00:00' && isset($version[0]) && $version[0]->fulltxt != '' ? 1 : 0, 'fulltxt' => isset($version[0]->fulltxt) ? $version[0]->fulltxt : $toolinfo[0]->rfulltxt, 'toolname' => isset($toolinfo[0]->toolname) ? $toolinfo[0]->toolname : '', 'toolid' => isset($toolinfo[0]->id) ? $toolinfo[0]->id : 0, 'title' => isset($version[0]->title) ? $version[0]->title : '', 'version' => isset($version[0]->version) ? $version[0]->version : '1.0', 'revision' => isset($version[0]->revision) ? $version[0]->revision : 0, 'description' => isset($version[0]->description) ? $version[0]->description : '', 'exec' => isset($version[0]->toolaccess) ? $version[0]->toolaccess : '@OPEN', 'code' => isset($version[0]->codeaccess) ? $version[0]->codeaccess : '@OPEN', 'wiki' => isset($version[0]->wikiaccess) ? $version[0]->wikiaccess : '@OPEN', 'published' => isset($toolinfo[0]->published) ? $toolinfo[0]->published : 0, 'state' => isset($toolinfo[0]->state) ? $toolinfo[0]->state : 0, 'version_state' => isset($version[0]->state) ? $version[0]->state : 3, 'version_id' => isset($version[0]->id) ? $version[0]->id : 0, 'priority' => isset($toolinfo[0]->priority) ? $toolinfo[0]->priority : 3, 'doi' => isset($version[0]->doi) ? $version[0]->doi : 0, 'authors' => $authors, 'developers' => $developers, 'devgroup' => isset($toolinfo[0]->devgroup) ? $toolinfo[0]->devgroup : '', 'membergroups' => isset($version[0]->toolaccess) && $version[0]->toolaccess == '@GROUP' ? $this->getToolGroups($toolinfo[0]->id) : array(), 'ntools' => isset($toolinfo[0]->ntools) ? $toolinfo[0]->ntools : 0, 'ntoolsdev' => isset($toolinfo[0]->ntoolsdev) ? $toolinfo[0]->ntoolsdev : 0, 'ntools_published' => isset($toolinfo[0]->ntoolspublished) ? $toolinfo[0]->ntoolspublished : 0, 'newmessages' => isset($toolinfo[0]->comments) ? $toolinfo[0]->comments : 0, 'changed' => isset($toolinfo[0]->state_changed) && $toolinfo[0]->state_changed != '0000-00-00 00:00:00' ? $toolinfo[0]->state_changed : $toolinfo[0]->registered, 'registered_by' => isset($toolinfo[0]->registered_by) ? $toolinfo[0]->registered_by : '', 'registered' => isset($toolinfo[0]->registered) ? $toolinfo[0]->registered : '', 'ticketid' => isset($toolinfo[0]->ticketid) ? $toolinfo[0]->ticketid : '', 'mw' => isset($version[0]->mw) ? $version[0]->mw : $mw, 'vncCommand' => isset($version[0]->vnc_command) ? $version[0]->vnc_command : $invokedir . DS . $toolinfo[0]->toolname . DS . 'invoke', 'vncGeometry' => isset($version[0]->vnc_geometry) && $version[0]->vnc_geometry != '' ? $version[0]->vnc_geometry : $vnc, 'license' => isset($version[0]->license) ? $version[0]->license : '', 'hostreq' => isset($version[0]->hostreq) ? implode(', ', $version[0]->hostreq) : $hostreq, 'params' => isset($version[0]->params) ? $version[0]->params : '', 'github' => $params->get('github'), 'publishType' => $params->get('publishType') == 'weber=' ? 'jupyter' : 'standard'); list($status['vncGeometryX'], $status['vncGeometryY']) = preg_split('#[x]#', $status['vncGeometry']); // get latest version information if ($status['published']) { $current = $objV->getVersionInfo('', 'current', $toolinfo[0]->toolname); } $status['currenttool'] = isset($current[0]->instance) ? $current[0]->instance : $status['toolname'] . $dev_suffix; $status['currentrevision'] = isset($current[0]->revision) ? $current[0]->revision : $status['revision']; $status['currentversion'] = isset($current[0]->version) ? $current[0]->version : $status['version']; return $status; }
/** * Send a message to one or more users * * @param string $type Message type (maps to #__xmessage_component table) * @param string $subject Message subject * @param string $message Message to send * @param array $from Message 'from' data (e.g., name, address) * @param array $to List of user IDs * @param string $component Component name * @param integer $element ID of object that needs an action item * @param string $description Action item description * @param integer $group_id Parameter description (if any) ... * @return mixed True if no errors else error message */ public function onSendMessage($type, $subject, $message, $from = array(), $to = array(), $component = '', $element = null, $description = '', $group_id = 0, $bypassGroupsCheck = false) { // Do we have a message? if (!$message) { return false; } $database = App::get('db'); // Create the message object $xmessage = Hubzero\Message\Message::blank(); if ($type == 'member_message') { $time_limit = intval($this->params->get('time_limit', 30)); $daily_limit = intval($this->params->get('daily_limit', 100)); // First, let's see if they've surpassed their daily limit for sending messages $filters = array('created_by' => User::get('id'), 'daily_limit' => $daily_limit); $number_sent = $xmessage->getSentMessagesCount($filters); if ($number_sent >= $daily_limit) { return false; } // Next, we see if they've passed the time limit for sending consecutive messages $filters['limit'] = 1; $filters['start'] = 0; $sent = $xmessage->getSentMessages($filters); if ($sent->count() > 0) { $last_sent = $sent->first(); $last_time = 0; if ($last_sent->created) { $last_time = Date::of($last_sent->created)->toUnix(); } $time_difference = Date::toUnix() + $time_limit - $last_time; if ($time_difference < $time_limit) { return false; } } } // Store the message in the database $xmessage->set('message', is_array($message) && isset($message['plaintext']) ? $message['plaintext'] : $message); // Do we have a subject line? If not, create it from the message if (!$subject && $xmessage->get('message')) { $subject = substr($xmessage->get('message'), 0, 70); if (strlen($subject) >= 70) { $subject .= '...'; } } $xmessage->set('subject', $subject); $xmessage->set('created', Date::toSql()); $xmessage->set('created_by', User::get('id')); $xmessage->set('component', $component); $xmessage->set('type', $type); $xmessage->set('group_id', $group_id); if (!$xmessage->save()) { return $xmessage->getError(); } if (is_array($message)) { $xmessage->set('message', $message); } // Do we have any recipients? if (count($to) > 0) { $mconfig = Component::params('com_members'); // Get all the sender's groups if ($mconfig->get('user_messaging', 1) == 1 && !$bypassGroupsCheck) { $xgroups = User::groups('all'); $usersgroups = array(); if (!empty($xgroups)) { foreach ($xgroups as $group) { if ($group->regconfirmed) { $usersgroups[] = $group->cn; } } } } // Loop through each recipient foreach ($to as $uid) { // Create a recipient object that ties a user to a message $recipient = Hubzero\Message\Recipient::blank(); $recipient->set('uid', $uid); $recipient->set('mid', $xmessage->get('id')); $recipient->set('created', Date::toSql()); $recipient->set('expires', Date::of(time() + 168 * 24 * 60 * 60)->toSql()); $recipient->set('actionid', 0); //(is_object($action)) ? $action->id : 0; [zooley] Phasing out action items // Get the user's methods for being notified $notify = Hubzero\Message\Notify::blank(); $methods = $notify->getRecords($uid, $type); $user = User::getInstance($uid); if (!is_object($user) || !$user->get('username')) { continue; } if ($mconfig->get('user_messaging', 1) == 1 && ($type == 'member_message' || $type == 'group_message')) { $pgroups = \Hubzero\User\Helper::getGroups($user->get('id'), 'all', 1); $profilesgroups = array(); if (!empty($pgroups)) { foreach ($pgroups as $group) { if ($group->regconfirmed) { $profilesgroups[] = $group->cn; } } } // Find the common groups if (!$bypassGroupsCheck) { $common = array_intersect($usersgroups, $profilesgroups); if (count($common) <= 0) { continue; } } } // Do we have any methods? if ($methods->count()) { // Loop through each method foreach ($methods as $method) { $action = strtolower($method->method); if ($action == 'internal') { if (!$recipient->save()) { $this->setError($recipient->getError()); } } else { if (!Event::trigger('onMessage', array($from, $xmessage, $user, $action))) { $this->setError(Lang::txt('PLG_XMESSAGE_HANDLER_ERROR_UNABLE_TO_MESSAGE', $uid, $action)); } } } } else { // First check if they have ANY methods saved (meaning they've changed their default settings) // If They do have some methods, then they simply turned off everything for this $type $methods = $notify->getRecords($uid); if (!$methods || $methods->count() <= 0) { // Load the default method $p = Plugin::byType('members', 'messages'); $pp = new \Hubzero\Config\Registry(is_object($p) ? $p->params : ''); $d = $pp->get('default_method', 'email'); if (!$recipient->save()) { $this->setError($recipient->getError()); } // Use the Default in the case the user has no methods if (!Event::trigger('onMessage', array($from, $xmessage, $user, $d))) { $this->setError(Lang::txt('PLG_XMESSAGE_HANDLER_ERROR_UNABLE_TO_MESSAGE', $uid, $d)); } } } } } return true; }
/** * Save blog settings * * @return void */ private function _savesettings() { if (User::isGuest()) { $this->setError(Lang::txt('GROUPS_LOGIN_NOTICE')); return; } if ($this->authorized != 'manager' && $this->authorized != 'admin') { $this->setError(Lang::txt('PLG_GROUPS_BLOG_NOT_AUTHORIZED')); return $this->_browse(); } // Check for request forgeries Request::checkToken(); $settings = Request::getVar('settings', array(), 'post'); $row = \Hubzero\Plugin\Params::blank()->set($settings); // Get parameters $p = new \Hubzero\Config\Registry(Request::getVar('params', array(), 'post')); $row->set('params', $p->toString()); // Store new content if (!$row->save()) { $this->setError($row->getError()); return $this->_settings(); } // Record the activity $recipients = array(['group', $this->group->get('gidNumber')]); foreach ($this->group->get('managers') as $recipient) { $recipients[] = ['user', $recipient]; } Event::trigger('system.logActivity', ['activity' => ['action' => 'updated', 'scope' => 'blog.settings', 'scope_id' => $row->get('id'), 'description' => Lang::txt('PLG_GROUPS_BLOG_ACTIVITY_SETTINGS_UPDATED')], 'recipients' => $recipients]); App::redirect(Route::url('index.php?option=com_groups&cn=' . $this->group->get('cn') . '&active=' . $this->_name . '&action=settings'), Lang::txt('PLG_GROUPS_BLOG_SETTINGS_SAVED'), 'passed'); }
/** * Get stored auth token for service * * @param string $param Param name * @param integer $uid User ID * * @return string */ public function getStoredParam($param, $uid = 0) { $uid = $uid ? $uid : $this->_uid; $objO = $this->model->table('Owner'); $objO->loadOwner($this->model->get('id'), $uid); $params = new \Hubzero\Config\Registry($objO->params); return $params->get($param); }
?> </td> <?php } ?> <td class="citation-container"> <?php $formatted = $cite->formatted ? $cite->formatted : $formatter->formatCitation($cite, $this->filters['search'], $coins, $this->config); if ($cite->doi) { $formatted = str_replace('doi:' . $cite->doi, '<a href="' . $cite->url . '" rel="external">' . 'doi:' . $cite->doi . '</a>', $formatted); } echo $formatted; ?> <?php //get this citations rollover param $params = new \Hubzero\Config\Registry($cite->params); $citation_rollover = $params->get('rollover', $rollover); ?> <?php if ($citation_rollover && $cite->abstract != "") { ?> <div class="citation-notes"> <?php $cs = new \Components\Citations\Tables\Sponsor($this->database); $sponsors = $cs->getCitationSponsor($cite->id); $final = ""; if ($sponsors) { foreach ($sponsors as $s) { $sp = $cs->getSponsor($s); if ($sp) { $final .= '<a rel="external" href="' . $sp[0]['link'] . '">' . $sp[0]['sponsor'] . '</a>, ';
/** * Lists projects * * @return void */ public function displayTask() { $this->view->config = $this->config; // Get quotas $this->view->defaultQuota = Helpers\Html::convertSize(floatval($this->config->get('defaultQuota', 1)), 'GB', 'b'); $this->view->premiumQuota = Helpers\Html::convertSize(floatval($this->config->get('premiumQuota', 30)), 'GB', 'b'); // Get filters $this->view->filters = array('limit' => Request::getState($this->_option . '.projects.limit', 'limit', Config::get('list_limit'), 'int'), 'start' => Request::getState($this->_option . '.projects.limitstart', 'limitstart', 0, 'int'), 'search' => urldecode(Request::getState($this->_option . '.projects.search', 'search', '')), 'sortby' => Request::getState($this->_option . '.projects.sort', 'filter_order', 'id'), 'sortdir' => Request::getState($this->_option . '.projects.sortdir', 'filter_order_Dir', 'DESC'), 'authorized' => true, 'getowner' => 1, 'activity' => 1, 'quota' => Request::getVar('quota', 'all', 'post')); $this->view->limit = $this->view->filters['limit']; $this->view->start = $this->view->filters['start']; // Retrieve all records when filtering by quota (no paging) if ($this->view->filters['quota'] != 'all') { $this->view->filters['limit'] = 'all'; $this->view->filters['start'] = 0; } $obj = new Tables\Project($this->database); // Get records $this->view->rows = $obj->getRecords($this->view->filters, true, 0, 1); // Get a record count $this->view->total = $obj->getCount($this->view->filters, true, 0, 1); // Filtering by quota if ($this->view->filters['quota'] != 'all' && $this->view->rows) { $counter = $this->view->total; $rows = $this->view->rows; for ($i = 0, $n = count($rows); $i < $n; $i++) { $params = new \Hubzero\Config\Registry($rows[$i]->params); $quota = $params->get('quota', 0); if ($this->view->filters['quota'] == 'premium' && $quota < $this->view->premiumQuota || $this->view->filters['quota'] == 'regular' && $quota > $this->view->defaultQuota) { $counter--; unset($rows[$i]); } } $rows = array_values($rows); $this->view->total = $counter > 0 ? $counter : 0; // Fix up paging after filter if (count($rows) > $this->view->limit) { $k = 0; for ($i = 0, $n = count($rows); $i < $n; $i++) { if ($k < $this->view->start || $k >= $this->view->limit + $this->view->start) { unset($rows[$i]); } $k++; } } $this->view->rows = array_values($rows); } // Set any errors if ($this->getError()) { $this->view->setError($this->getError()); } // Check that master path is there if ($this->config->get('offroot') && !is_dir($this->config->get('webpath'))) { $this->view->setError(Lang::txt('Master directory does not exist. Administrator must fix this! ') . $this->config->get('webpath')); } // Output the HTML $this->view->display(); }
?> <form action="<?php echo Route::url('index.php?option=' . $this->option . '&' . ($this->task == 'create' ? 'return=' . $form_redirect : 'task=' . $this->task)); ?> " method="post" id="hubForm"> <?php if ($this->task == 'create' && empty($this->xregistration->_invalid) && empty($this->xregistration->_missing)) { // Check to see if third party auth plugins are enabled Plugin::import('authentication'); $plugins = Plugin::byType('authentication'); $authenticators = array(); foreach ($plugins as $p) { if ($p->name != 'hubzero') { $pparams = new \Hubzero\Config\Registry($p->params); $display = $pparams->get('display_name', ucfirst($p->name)); $authenticators[] = array('name' => $p->name, 'display' => $display); } } // There are third party plugins, so show them on the registration form if (!empty($authenticators)) { $this->css('providers.css', 'com_users'); ?> <div class="explaination"> <p class="info">You can choose to log in via one of these services, and we'll help you fill in the info below!</p> <p>Already have an account? <a href="<?php echo Route::url('index.php?option=com_users&view=login'); ?> ">Log in here.</a></p> </div>