/**
  * 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();
 }
Exemplo n.º 2
0
 /**
  * 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];
 }
Exemplo n.º 3
0
 /**
  * Method to get a single record.
  *
  * @param   integer  $pk  The id of the primary key.
  *
  * @return  mixed  Object on success, false on failure.
  *
  * @since   1.6
  */
 public function getItem($pk = null)
 {
     // Initialise variables.
     $pk = !empty($pk) ? (int) $pk : (int) $this->getState('module.id');
     $db = $this->getDbo();
     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 && ($error = $table->getError())) {
             $this->setError($error);
             return $false;
         }
         // Check if we are creating a new extension.
         if (empty($pk)) {
             if ($extensionId = (int) $this->getState('extension.id')) {
                 $query = $db->getQuery(true);
                 $query->select('element, client_id');
                 $query->from('#__extensions');
                 $query->where('extension_id = ' . $extensionId);
                 $query->where('type = ' . $db->quote('module'));
                 $db->setQuery($query);
                 $extension = $db->loadObject();
                 if (empty($extension)) {
                     if ($error = $db->getErrorMsg()) {
                         $this->setError($error);
                     } else {
                         $this->setError('COM_MODULES_ERROR_CANNOT_FIND_MODULE');
                     }
                     return false;
                 }
                 // Extension found, prime some module values.
                 $table->module = $extension->element;
                 $table->client_id = $extension->client_id;
             } else {
                 App::redirect(Route::url('index.php?option=com_modules&view=modules', false));
                 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();
         // Determine the page assignment mode.
         $db->setQuery('SELECT menuid' . ' FROM #__modules_menu' . ' WHERE moduleid = ' . $pk);
         $assigned = $db->loadColumn();
         if (empty($pk)) {
             // If this is a new module, assign to all pages.
             $assignment = 0;
         } elseif (empty($assigned)) {
             // For an existing module it is assigned to none.
             $assignment = '-';
         } else {
             if ($assigned[0] > 0) {
                 $assignment = +1;
             } elseif ($assigned[0] < 0) {
                 $assignment = -1;
             } else {
                 $assignment = 0;
             }
         }
         $this->_cache[$pk]->assigned = $assigned;
         $this->_cache[$pk]->assignment = $assignment;
         // Get the module XML.
         //$client = \Hubzero\Base\ClientManager::client($table->client_id);
         //$path   = JPath::clean($client->path.'/modules/'.$table->module.'/'.$table->module.'.xml');
         $patha = JPath::clean(PATH_APP . '/modules/' . $table->module . '/' . $table->module . '.xml');
         $pathc = JPath::clean(PATH_CORE . '/modules/' . $table->module . '/' . $table->module . '.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];
 }
Exemplo n.º 4
0
 /**
  * Process Import data
  *
  * @access public
  * @param  Closure Object
  */
 public function process(\Components\Resources\Models\Import $import, array $callbacks, $dryRun)
 {
     // create new xml reader
     $iterator = new \Components\Resources\Import\Iterators\Csv($import->getDatapath(), $this->delimiter);
     // get the import params
     $options = new \Hubzero\Config\Registry($import->get('params'));
     // get the mode
     $mode = $import->get('mode', 'UPDATE');
     // loop through each item
     foreach ($iterator as $index => $record) {
         // make sure we have a record
         if ($record === null) {
             continue;
         }
         // do we have a post parse callback ?
         $record = $this->map($record, $callbacks['postparse'], $dryRun);
         // convert to resource objects
         $resource = new \Components\Resources\Models\Import\Record($record, $options->toArray(), $mode);
         // do we have a post map callback ?
         $resource = $this->map($resource, $callbacks['postmap'], $dryRun);
         // run resource check & store
         $resource->check()->store($dryRun);
         // do we have a post convert callback ?
         $resource = $this->map($resource, $callbacks['postconvert'], $dryRun);
         // add to data array
         array_push($this->data, $resource);
         // mark record processed
         $import->runs('current')->processed(1);
     }
     return $this->data;
 }
Exemplo n.º 5
0
 /**
  * Method to get the profile form data.
  *
  * The base form data is loaded and then an event is fired
  * for users plugins to extend the data.
  *
  * @return	mixed		Data object on success, false on failure.
  * @since	1.6
  */
 public function getData()
 {
     if ($this->data === null) {
         $userId = $this->getState('user.id');
         // Initialise the table with JUser.
         $this->data = new JUser($userId);
         // Set the base user data.
         $this->data->email1 = $this->data->get('email');
         $this->data->email2 = $this->data->get('email');
         // Override the base user data with any data in the session.
         $temp = (array) JFactory::getApplication()->getUserState('com_users.edit.profile.data', array());
         foreach ($temp as $k => $v) {
             $this->data->{$k} = $v;
         }
         // Unset the passwords.
         unset($this->data->password1);
         unset($this->data->password2);
         $registry = new \Hubzero\Config\Registry($this->data->params);
         $this->data->params = $registry->toArray();
         // Trigger the data preparation event.
         $results = Event::trigger('user.onContentPrepareData', array('com_users.profile', $this->data));
         // Check for errors encountered while preparing the data.
         if (count($results) && in_array(false, $results, true)) {
             $this->setError($dispatcher->getError());
             $this->data = false;
         }
     }
     return $this->data;
 }
Exemplo n.º 6
0
?>
><?php 
echo Lang::txt('JYes');
?>
</option>
			</select>
		</p>

<?php 
if ($plugins = Event::trigger('courses.onAssetgroupEdit')) {
    $data = $ag->get('params');
    foreach ($plugins as $plugin) {
        $p = Plugin::byType('courses', $plugin['name']);
        $default = new \Hubzero\Config\Registry($p->params);
        $param = new JParameter(is_object($data) ? $data->toString() : $data, PATH_CORE . DS . 'plugins' . DS . 'courses' . DS . $plugin['name'] . DS . $plugin['name'] . '.xml');
        foreach ($default->toArray() as $k => $v) {
            if (substr($k, 0, strlen('default_')) == 'default_') {
                $param->def(substr($k, strlen('default_')), $default->get($k, $v));
            }
        }
        $out = $param->render('params', 'onAssetgroupEdit');
        if (!$out) {
            continue;
        }
        ?>
			<fieldset class="eventparams" id="params-<?php 
        echo $plugin['name'];
        ?>
">
				<legend><?php 
        echo Lang::txt('%s Parameters', $plugin['title']);
Exemplo n.º 7
0
 */
// No direct access
defined('_HZEXEC_') or die;
// create user params registry
$params = new \Hubzero\Config\Registry($this->module->params);
// load module params fields
$fields = new JForm($this->module->module);
$fields->loadFile(PATH_CORE . DS . 'modules' . DS . $this->module->module . DS . $this->module->module . '.xml', true, 'config/fields');
// This is done first as the 'renderModule' method loads the language file
// which is needed when rendering the params below
$module = Module::render($this->module, array('style' => 'none'));
// create settings sub view
$view = $this->view('parameters');
$view->admin = $this->admin;
$view->module = $this->module;
$view->params = $params->toArray();
$view->fields = $fields->getFieldset('basic');
$settingsHtml = trim($view->loadTemplate());
?>

<div class="module <?php 
echo strtolower($this->module->module) . ' ' . $params->get('moduleclass_sfx');
?>
  draggable sortable"
	data-row="<?php 
echo $this->module->positioning->row;
?>
"
	data-col="<?php 
echo $this->module->positioning->col;
?>
Exemplo n.º 8
0
 /**
  * Method to get a menu item.
  *
  * @param	integer	$pk	An optional id of the object to get, otherwise the id from the model state is used.
  *
  * @return	mixed	Menu item data object on success, false on failure.
  * @since	1.6
  */
 public function getItem($pk = null)
 {
     // Initialise variables.
     $pk = !empty($pk) ? $pk : (int) $this->getState('item.id');
     // Get a level row instance.
     $table = $this->getTable();
     // Attempt to load the row.
     $table->load($pk);
     // Check for a table object error.
     if ($error = $table->getError()) {
         $this->setError($error);
         $false = false;
         return $false;
     }
     // Prime required properties.
     if ($type = $this->getState('item.type')) {
         $table->type = $type;
     }
     if (empty($table->id)) {
         $table->parent_id = $this->getState('item.parent_id');
         $table->menutype = $this->getState('item.menutype');
         $table->params = '{}';
     }
     // If the link has been set in the state, possibly changing link type.
     if ($link = $this->getState('item.link')) {
         // Check if we are changing away from the actual link type.
         if (MenusHelper::getLinkKey($table->link) != MenusHelper::getLinkKey($link)) {
             $table->link = $link;
         }
     }
     switch ($table->type) {
         case 'alias':
             $table->component_id = 0;
             $args = array();
             parse_str(parse_url($table->link, PHP_URL_QUERY), $args);
             break;
         case 'separator':
             $table->link = '';
             $table->component_id = 0;
             break;
         case 'url':
             $table->component_id = 0;
             parse_str(parse_url($table->link, PHP_URL_QUERY));
             break;
         case 'component':
         default:
             // Enforce a valid type.
             $table->type = 'component';
             // Ensure the integrity of the component_id field is maintained, particularly when changing the menu item type.
             $args = array();
             parse_str(parse_url($table->link, PHP_URL_QUERY), $args);
             if (isset($args['option'])) {
                 // Load the language file for the component.
                 $lang = Lang::getRoot();
                 $lang->load($args['option'], PATH_APP, null, false, true) || $lang->load($args['option'], PATH_APP . '/components/' . $args['option'] . '/admin', null, false, true) || $lang->load($args['option'], PATH_CORE . '/components/' . $args['option'] . '/admin', null, false, true);
                 // Determine the component id.
                 $component = Component::load($args['option']);
                 if (isset($component->id)) {
                     $table->component_id = $component->id;
                 }
             }
             break;
     }
     // We have a valid type, inject it into the state for forms to use.
     $this->setState('item.type', $table->type);
     // Convert to the Object before adding the params.
     $properties = $table->getProperties(1);
     $result = \Hubzero\Utility\Arr::toObject($properties, '\\Hubzero\\Base\\Object');
     // Convert the params field to an array.
     $registry = new \Hubzero\Config\Registry($table->params);
     $result->params = $registry->toArray();
     // Merge the request arguments in to the params for a component.
     if ($table->type == 'component') {
         // Note that all request arguments become reserved parameter names.
         $result->request = $args;
         $result->params = array_merge($result->params, $args);
     }
     if ($table->type == 'alias') {
         // Note that all request arguments become reserved parameter names.
         $args = array();
         parse_str(parse_url($table->link, PHP_URL_QUERY), $args);
         $result->params = array_merge($result->params, $args);
     }
     if ($table->type == 'url') {
         // Note that all request arguments become reserved parameter names.
         $args = array();
         parse_str(parse_url($table->link, PHP_URL_QUERY), $args);
         $result->params = array_merge($result->params, $args);
     }
     // Load associated menu items
     if (JFactory::getApplication()->get('menu_associations', 0)) {
         if ($pk != null) {
             $result->associations = MenusHelper::getAssociations($pk);
         } else {
             $result->associations = array();
         }
     }
     $result->menuordering = $pk;
     return $result;
 }
Exemplo n.º 9
0
 /**
  * Method to get a single record.
  *
  * @param	integer	The id of the primary key.
  *
  * @return	mixed	Object on success, false on failure.
  * @since	1.6
  */
 public function getItem($pk = null)
 {
     if ($item = parent::getItem($pk)) {
         // Convert the params field to an array.
         $registry = new \Hubzero\Config\Registry($item->metadata);
         $item->metadata = $registry->toArray();
     }
     return $item;
 }
Exemplo n.º 10
0
 /**
  * Method to get a category.
  *
  * @param   integer  $pk  An optional id of the object to get, otherwise the id from the model state is used.
  *
  * @return  mixed  Category data object on success, false on failure.
  *
  * @since   1.6
  */
 public function getItem($pk = null)
 {
     if ($result = parent::getItem($pk)) {
         // Prime required properties.
         if (empty($result->id)) {
             $result->parent_id = $this->getState('category.parent_id');
             $result->extension = $this->getState('category.extension');
         }
         // Convert the metadata field to an array.
         $registry = new \Hubzero\Config\Registry($result->metadata);
         $result->metadata = $registry->toArray();
         // Convert the created and modified dates to local user time for display in the form.
         $tz = new DateTimeZone(Config::get('offset'));
         if (intval($result->created_time)) {
             $date = Date::of($result->created_time);
             $date->setTimezone($tz);
             $result->created_time = $date->toSql(true);
         } else {
             $result->created_time = null;
         }
         if (intval($result->modified_time)) {
             $date = Date::of($result->modified_time);
             $date->setTimezone($tz);
             $result->modified_time = $date->toSql(true);
         } else {
             $result->modified_time = null;
         }
     }
     return $result;
 }
Exemplo n.º 11
0
 /**
  * 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)
 {
     if ($item = parent::getItem($pk)) {
         // Convert the params field to an array.
         $registry = new \Hubzero\Config\Registry($item->attribs);
         $item->attribs = $registry->toArray();
         // Convert the metadata field to an array.
         $registry = new \Hubzero\Config\Registry($item->metadata);
         $item->metadata = $registry->toArray();
         // Convert the images field to an array.
         $registry = new \Hubzero\Config\Registry($item->images);
         $item->images = $registry->toArray();
         // Convert the urls field to an array.
         $registry = new \Hubzero\Config\Registry($item->urls);
         $item->urls = $registry->toArray();
         $item->articletext = trim($item->fulltext) != '' ? $item->introtext . "<hr id=\"system-readmore\" />" . $item->fulltext : $item->introtext;
     }
     return $item;
 }