public function importXml(SimpleXMLElement $xml) { parent::importXml($xml); foreach ($this->_xml->option as $option) { $elem = KFactory::tmp('admin::com.ninja.form.element.select.radio')->importXml($option); $this->addOption($elem); } if ($this->_xml['get']) { $get = isset($this->_xml['tmp']) && $this->_xml['tmp'] == true ? KFactory::tmp(new KIdentifier($this->_xml['get'])) : KFactory::get(new KIdentifier($this->_xml['get'])); if ($this->_xml['set']) { $json = '{"' . str_replace(array(';', ':'), array('","', '":"'), (string) $this->_xml['set']) . '"}'; $states = json_decode(str_replace('",""}', '"}', $json)); foreach ($states as $state => $set) { $get->{$state}($set); } } $key = $this->_xml['key'] ? $this->_xml['key'] : 'title'; $val = $this->_xml['val'] ? $this->_xml['val'] : 'id'; foreach ($get->getList() as $item) { $string = '<option value="' . $item->{$val} . '">' . $item->{$key} . '</option>'; $elem = KFactory::tmp('admin::com.ninja.form.element.select.radio')->importXml(simplexml_load_string($string)); $this->addOption($elem); } } return $this; }
public function __construct(KConfig $config) { $sluggable = KFactory::tmp('lib.koowa.database.behavior.sluggable', array('columns' => array('name'))); $config->table_behaviors = array($sluggable, 'orderable', 'lockable', 'creatable', 'modifiable'); parent::__construct($config); $this->_state->insert('jedi_rank_id', 'int')->insert('enabled', 'int'); }
public function display() { // Display the toolbar $toolbar = $this->_createToolbar()->reset(); $this->toolbar = KFactory::get($this->getToolbar(), array('isGrid' => false))->append(KFactory::get('admin::com.ninja.toolbar.button.apply', array('isGrid' => false))); KFactory::get('admin::com.ninja.helper.default')->css('/' . $this->getIdentifier()->application . '.' . $this->getName() . '.css'); KFactory::get('admin::com.ninja.helper.default')->js('/raphael.js'); KFactory::get('admin::com.ninja.helper.default')->js('/Mapper.js'); $acl = JFactory::getACL(); //die('<pre>'.print_r(get_class_methods($acl), true).'</pre>'); $acltree = (array) $acl->get_group_children_tree(null, 'USERS', false); array_unshift($acltree, (object) array('value' => 0, 'text' => 'Unregistered', 'disabled' => false)); $this->acltree = $acltree; $this->usergroups = KFactory::tmp('admin::com.ninjaboard.model.usergroups')->limit(0)->getList(); $maps = array(); foreach (KFactory::tmp($this->getModel()->getIdentifier())->limit(0)->getList() as $map) { $maps[$map->id] = $map->ninjaboard_gid; } $this->maps = $maps; $display = parent::display(); if (KRequest::type() == 'AJAX') { echo '<script type="text/javascript"> ' . $this->_document->_script['text/javascript'] . ' </script>'; } return $display; }
/** * Generic function for setting the permissions * * @return void */ public function setPermissions($context) { //Temp fix if (KInflector::isPlural(KRequest::get('get.view', 'cmd')) || KRequest::type() == 'AJAX') { return; } $model = KFactory::get($this->getModel()); $table = KFactory::tmp(KFactory::get(KFactory::get('admin::com.ninja.helper.access')->models->assets)->getTable()); $query = $table->getDatabase()->getQuery(); $item = $model->getItem(); $identifier = $this->getIdentifier(); $id = $identifier->type . '_' . $identifier->package . '.' . $identifier->name . '.' . $item->id . '.'; $permissions = (array) KRequest::get('post.permissions', 'int'); $editable = KRequest::get('post.editpermissions', 'boolean', false); if (!$permissions && $editable) { $query->where('tbl.name', 'LIKE', $id . '%'); $table->select($query)->delete(); } $safe = array(); $query = $table->getDatabase()->getQuery()->where('name', 'like', $id . '%'); foreach ((array) KRequest::get('post.params.permissions', 'raw') as $group => $other) { $safe[] = $id . $group; } if ($safe) { $query->where('name', 'not in', $safe); } $table->select($query, KDatabase::FETCH_ROWSET)->delete(); foreach ($permissions as $usergroup => $rules) { foreach ($rules as $name => $permission) { KFactory::tmp(KFactory::get('admin::com.ninja.helper.access')->models->assets)->name($id . $usergroup . '.' . $name)->getItem()->setData(array('name' => $id . $usergroup . '.' . $name, 'level' => $permission))->save(); } } }
public function display($tpl = null) { $nooku = KFactory::get('admin::com.nooku.model.nooku'); $model = KFactory::get('admin::com.nooku.model.translators'); // Get data from model $stats = $model->getStats(); $dates = $model->getDates(); // Get translators $translators = $nooku->getTranslators(); // Get the languages //$primary = $nooku->getPrimaryLanguage(); $languages = $nooku->getLanguages(); //unset($languages[$primary->iso_code]); // we don't display the primary lang in our chart // Request $table_name = KInput::get('table_name', 'get', KFactory::tmp('admin::com.nooku.filter.tablename')); $user_id = KInput::get('user_id', 'get', 'int'); if (!$user_id) { throw new KViewException('user_id is required in ' . JURI::getInstance()->toString()); } // Utilities $color = new NookuConfigColor(); // get the chart $c = $this->getChart('line'); // Data $i = 1; foreach ($stats[$user_id]->count as $value) { $c->setData($i++, $value); } // Layout $c->SetLineSize(5); // The Sparkline lib always draws in black, this hack lets us use other colors $c->setColor('black', $color->get('blue')); parent::display(); }
/** * Retrieve row field value * * @param string The column name. * @return string The corresponding column value. */ public function __get($column) { if (strpos($column, '_permissions') === false) { return parent::__get($column); } $object = str_replace('_permissions', '', $column); if (!isset($this->_permissions[$object])) { $table = KFactory::get('admin::com.ninjaboard.database.table.assets'); $query = KFactory::tmp('lib.koowa.database.query'); $me = KFactory::get('admin::com.ninjaboard.model.people')->getMe(); $gids = explode('|', $me->ninjaboard_usergroup_id); //If super admin, then the permission level is always 3 if ($me->gid == 25) { return $this->_permissions[$object] = 3; } $query->select('IFNULL(tbl.level, ' . (int) $me->{$object . '_permissions'} . ') AS level')->from('ninjaboard_assets AS tbl')->order('tbl.level', 'DESC')->limit(1); $where = array(); foreach ($gids as $gid) { $where[] = 'com_ninjaboard.forum.' . (int) $this->id . '.' . $gid . '.' . $object; } if ($where) { $query->where('tbl.name', 'in', $where); } $result = $table->getDatabase()->select($query, KDatabase::FETCH_FIELD); $this->_permissions[$object] = is_numeric($result) ? $result : $me->{$object . '_permissions'}; } return $this->_permissions[$object]; }
public function display($tpl = null) { $nooku = KFactory::get('admin::com.nooku.model.nooku'); $model = KFactory::get('admin::com.nooku.model.translations'); // Get data $stats = $model->getStats(); $iso_code = KInput::get('iso_code', 'get', 'lang'); // Requested table $table_name = KInput::get('table_name', 'get', KFactory::tmp('admin::com.nooku.filter.tablename')); // Utilities $color = new NookuConfigColor(); // get the chart $c = $this->getChart('bar'); $c->setColor('red', $color->get('red')); $c->setColor('blue', $color->get('blue')); $c->setColor('yellow', $color->get('yellow')); $c->setColor('green', $color->get('green')); $c->SetBarWidth(5); $c->SetBarSpacing(1); $c->setData(0, $stats['MISSING'][$iso_code], 'red'); $c->setData(1, $stats['OUTDATED'][$iso_code], 'yellow'); $c->setData(2, $stats['COMPLETED'][$iso_code], 'green'); $c->setData(3, $stats['ORIGINAL'][$iso_code], 'blue'); return parent::display(); }
public function _actionEdit(KCommandContext $context) { $data = $context->data; $model = $this->getModel(); $table = $model->getTable(); $query = KFactory::tmp('lib.koowa.database.query'); $ids = array(); foreach ($data['group'] as $joomla => $ninjaboard) { $ids[] = $joomla; } $table->getDatabase()->execute('TRUNCATE TABLE `#__ninjaboard_joomla_user_group_maps`'); foreach ($ids as $id) { $table->getDatabase()->execute('INSERT INTO `#__ninjaboard_joomla_user_group_maps` (`joomla_gid`, `ninjaboard_gid`) VALUES (' . $id . ', ' . (int) $data['group'][$id] . ')'); //$table->insert(array('joomla_gid' => $id, 'ninjaboard_gid' => $data['group'][$id])); } $tmpl = false; if (KRequest::get('post.tmpl', 'cmd') == 'component') { $tmpl = '&tmpl=component'; } $this->_redirect = 'index.php?option=com_ninjaboard&view=joomlausergroupmaps' . $tmpl; if ($tmpl) { $this->_redirect_message = '<script type="text/javascript">window.parent.document.getElementById("sbox-btn-close").fireEvent("click")</script>'; } // @TODO this is a temporary workaround, find out why the proper way, using setRedirect(), stopped working. echo $this->_redirect_message; //$this->setRedirect('view=joomlausergroupmaps'.$tmpl, $tmpl ? '<script type="text/javascript">window.parent.document.getElementById("sbox-btn-close").fireEvent("click")</script>' : null); return $this->getModel()->getList(); }
public function display() { $targets = KFactory::tmp('site::com.stream.model.targets')->getList()->getData(); $thing = reset($targets); $string = substr($thing['title'], 3); $option = strtolower(substr($string, 0, stripos($string, 'controller'))); $view = strtolower(substr($string, stripos($string, 'controller') + 10)); $model = KInflector::pluralize($view); $list = KFactory::tmp('site::com.' . $option . '.model.' . $model)->getList()->getData(); $array = array(); foreach ($list as $item) { $array[] = $item['id']; } //Get the list of posts $activities = KFactory::get($this->getModel())->set('parent_target_id', KRequest::get('get.parent_target_id', 'int'))->getList(); $myactivities = array(); foreach (@$activities as $activity) { if (!in_array($activity->parent_target_id, $array)) { continue; } else { $myactivities[] = $activity; } } $this->assign('myactivities', $myactivities); $this->assign('pagination', KFactory::get($this->getModel())->getState()->pagination); return parent::display(); }
public function render() { $id = 'toolbar-' . $this->getName(); $html = array(); // Start toolbar div if (JVERSION::isCompatible('1.6')) { $html[] = '<div class="toolbar-list" id="' . $id . '">'; } else { $html[] = '<div class="toolbar" id="' . $id . '">'; } $html[] = '<table class="toolbar"><tr>'; // Render each button in the toolbar foreach ($this->_buttons as $button) { if (!$button instanceof KToolbarButtonInterface) { $app = $this->_identifier->application; $package = $this->_identifier->package; $button = KFactory::tmp($app . '::com.' . $package . '.toolbar.button.' . $button); } $button->setParent($this); $html[] = $button->render(); } // End toolbar div $html[] = '</tr></table>'; $html[] = '</div>'; return implode(PHP_EOL, $html); }
public function display($tpl = null) { $menu = JSite::getMenu(); $params = $menu->getParams($menu->getActive()->id); $url = KFactory::tmp('lib.koowa.filter.url')->sanitize($params->get('url')); KFactory::get('lib.joomla.application')->redirect($url); }
public function fetchElement($name, $value, &$node, $control_name) { $buffer = ''; $chain = $node->children(); if (!defined('NINJA_CHAIN')) { $document = KFactory::get('lib.joomla.document'); $document->addStyleDeclaration("\n\t\t\t\t.wrapper {\n\t\t\t\t\t-webkit-border-radius: 3px;\n\t\t\t\t\t-moz-border-radius: 3px;\n\t\t\t\t\tborder-radius: 3px;\n\t\t\t\t\tbackground-color: #EBEBEB;\n\t\t\t\t\tbackground-color: hsla(0, 0%, 94%, 0.8);\n\t\t\t\t\tborder: 1px solid #E6E6E6;\n\t\t\t\t\tborder-color: hsla(0, 0%, 90%, 0.8);\n\t\t\t\t\toverflow: hidden;\n\t\t\t\t\tpadding: 6px;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t.wrapper .chain-label {\n\t\t\t\t\tdisplay: block;\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\t.wrapper .chain .value, .wrapper .chain ul.group {\n\t\t\t\t\tmargin-left: auto!important;\n\t\t\t\t}\n\t\t\t"); define('NINJA_CHAIN', 1); } // $buffer .= "<div class='wrapper'>"; foreach ($chain as $item) { //get the type of the parameter $type = (string) $item['type']; try { $identifier = new KIdentifier($type); } catch (KException $e) { $identifier = 'admin::com.ninja.element.' . $type; } $chaindata = $this->_parent->get((string) $node['name']); if (isset($chaindata[(string) $item['name']]) && $chaindata[(string) $item['name']] !== false) { $value = $chaindata[(string) $item['name']]; } else { $value = (string) $item['default']; } $element = KFactory::tmp($identifier, array('parent' => $this->_parent, 'node' => $item, 'value' => $value, 'field' => $this->field, 'group' => $this->_parent->getGroup(), 'name' => $name . '[' . (string) $item['name'] . ']', 'fetchTooltip' => false)); $buffer .= '<div class="chain ' . $name . '_' . (string) $item['name'] . ' chain-' . $type . '">'; $buffer .= '<span class="chain-label">' . JText::_($element->label) . '</span>'; $buffer .= $element->toString(); $buffer .= "</div>"; } $buffer .= "</div>"; return $buffer; }
public function render() { $name = $this->getName(); $img = KTemplateAbstract::loadHelper('admin::com.ninja.helper.default.img', '/32/' . $name . '.png'); if ($img) { KTemplateAbstract::loadHelper('admin::com.ninja.helper.default.css', '.toolbar .icon-32-' . $name . ' { background-image: url(' . $img . '); }'); } $text = JText::_($this->_options['text']); $view = KRequest::get('get.view', 'cmd'); $link = ' href="' . JRoute::_($this->getLink()) . '"'; $html = array(); // Sanitize the url since we can't trust the server var $url = KFactory::get('lib.koowa.filter.url')->sanitize($this->getLink()); // Create the URI object $uri = KFactory::tmp('lib.koowa.http.uri', array('uri' => $url)); $query = $uri->getQuery(1); $html[] = '<td class="button" id="' . $this->getId() . '">'; $active = $view == KInflector::variablize(KInflector::pluralize($query['view'])) || $view == KInflector::variablize(KInflector::singularize($query['view'])); $hide = !KInflector::isPlural($view); if ($active || $hide || !$this->modal) { $html[] = '<a class="toolbar inactive">'; } else { $html[] = '<a' . $link . ' onclick="' . $this->getOnClick() . '" class="toolbar">'; } $html[] = '<span class="' . $this->getClass() . '" title="' . $text . '">'; $html[] = '</span>'; $html[] = $text; if (!$active && !$hide || $this->modal) { $html[] = '</a>'; } else { $html[] = '</a>'; } $html[] = '</td>'; return implode(PHP_EOL, $html); }
/** * Renders the html markup for the user avatar * * @author Stian Didriksen <*****@*****.**> * @return string */ public function image($config = array()) { $params = KFactory::get('admin::com.ninjaboard.model.settings')->getParams(); $prepend = KFactory::get('lib.joomla.application')->isAdmin() ? KRequest::root() . '/' : ''; $config = new KConfig($config); $config->append(array('id' => KFactory::get('admin::com.ninjaboard.model.people')->getMe()->id, 'thumbnail' => 'large', 'class' => 'avatar', 'link' => 'person', 'type' => 'css')); $person = KFactory::tmp('admin::com.ninjaboard.model.people')->id($config->id)->getItem(); $avatar_on = new DateTime($person->avatar_on); $cache = (int) $avatar_on->format('U'); $config->append(array('avatarurl' => $prepend . JRoute::_('&option=com_ninjaboard&view=avatar&id=' . $config->id . '&thumbnail=' . $config->thumbnail . '&cache=' . $cache), 'profileurl' => $prepend . JRoute::_('&option=com_ninjaboard&view=person&id=' . $config->id))); $attribs = array('class' => $config->class, 'href' => $config->profileurl); $height = $params['avatar_settings'][$config->thumbnail . '_thumbnail_height']; $width = $params['avatar_settings'][$config->thumbnail . '_thumbnail_width']; ///* @TODO Following is the <img /> version, likely going to be deprecated if ($config->type == 'tag') { $attribs['src'] = $config->avatarurl; $attribs['height'] = $height; $attribs['width'] = $width; unset($attribs['href']); $html = '<img ' . KHelperArray::toString($attribs) . ' />'; } else { $style = 'background-image: url(' . $config->avatarurl . '); '; $style .= 'height: ' . $height . 'px; '; $style .= 'width: ' . $width . 'px;'; $attribs['style'] = $style; $html = '<a ' . KHelperArray::toString($attribs) . '></a>'; } return $html; }
public function display($tpl = null) { // Request $month = KInput::get('month', 'get', 'digit', null, date('m')); $year = KInput::get('year', 'get', 'int', null, date('Y')); $graph = KInput::get('graph', 'get', 'cmd', null, 'translations'); $table_name = KInput::get('table_name', 'get', KFactory::tmp('admin::com.nooku.filter.tablename'), null, ''); $this->assign('graph', $graph); $this->assign('table_name', $table_name); $this->assign('month', $month); $this->assign('year', $year); // URI $uri =& JURI::getInstance(JURI::base() . 'index.php?option=com_nooku&format=openflashchart'); $uri->setVar('table_name', $table_name); $uri->setVar('layout', 'bar'); $uri->setVar('view', 'statistics.translations'); $this->assign('translations', $uri->toString()); $uri->setVar('year', date('Y')); $uri->setVar('month', date('n')); $uri->setVar('view', 'statistics.translators'); $this->assign('translators', $uri->toString()); // panes Koowa::import('lib.joomla.html.pane'); $this->assignRef('panes', JPane::getInstance('tabs')); // Mixin a menubar object $this->mixin(new NookuMixinMenu($this)); $this->displayMenubar(); $this->displayMenutitle(); $this->displayToolbar(); // Display the layout parent::display($tpl); }
public function display() { $topic = $this->getModel()->getItem(); $this->forum = KFactory::get('site::com.ninjaboard.model.forums')->id($topic->forum_id)->getItem(); $this->user = KFactory::get('lib.joomla.user'); $me = KFactory::get('admin::com.ninjaboard.model.people')->getMe(); $this->watch_button = $me->id && $this->forum->params['email_notification_settings']['enable_email_notification']; //Assign forum permissions to topic $topic->forum_permissions = $this->forum->forum_permissions; $topic->topic_permissions = $this->forum->topic_permissions; $topic->post_permissions = $this->forum->post_permissions; $topic->attachment_permissions = $this->forum->attachment_permissions; if ((!$this->forum->id || !$topic->id || $topic->topic_permissions < 1) && KFactory::tmp('lib.joomla.user')->guest) { $this->mixin(KFactory::get('admin::com.ninja.view.user.mixin')); $this->setLoginLayout(); return parent::display(); } elseif (!$topic->id) { JError::raiseError(404, JText::_("Topic not found.")); return; } elseif (!$this->forum->id) { JError::raiseError(404, JText::_("Forum not found.")); return; } $this->_subtitle = $topic->title; //if($topic->id && !KRequest::get('get.layout', 'cmd', false)) $this->setLayout('default'); $state = $this->getModel()->getState(); $limit = $state->limit ? $state->limit : 6; $offset = KFactory::tmp('site::com.ninjaboard.model.posts')->topic($topic->id)->post($state->post)->limit($limit)->getOffset(); $offset = KRequest::get('get.offset', 'int', $offset); //This is used to set the canonical link correctly in the topic controller after.read //@TODO move all this logic out of the view in 1.2 $this->getModel()->set(array('limit' => $limit, 'offset' => $offset)); $this->assign('posts', KFactory::tmp('site::com.ninjaboard.controller.post')->setView(KFactory::tmp('site::com.ninjaboard.view.posts.html'))->setModel(KFactory::get('site::com.ninjaboard.model.posts')->setAcl(false))->sort('created_on')->limit($limit)->offset($offset)->post(false)->topic($topic->id)->layout('default')->display()); if ($this->forum->params['view_settings']['new_topic_button'] == 'topic') { $this->new_topic_button = '<div class="new-topic">' . str_replace(array('$title', '$link'), array(JText::_('New Topic'), $this->createRoute('view=post&forum=' . $this->forum->id)), $this->forum->params['tmpl']['new_topic_button']) . '</div>'; } $button = false; if (KFactory::get('lib.joomla.user')->guest || $this->forum->post_permissions > 1) { $button = str_replace(array('$title', '$link'), array(JText::_('Reply topic'), $this->createRoute('view=post&topic=' . $topic->id)), $this->forum->params['tmpl']['new_topic_button']); } //$this->reply_topic_button = $this->forum->post_permissions > 1 ? $button : null; $this->reply_topic_button = $button; $this->lock_topic_button = null; $this->move_topic_button = null; $this->delete_topic_button = null; if ($this->forum->topic_permissions > 2) { $this->lock_topic_button = $this->_createActionButton('lock', 'Lock topic', $topic->id, 'lock'); $this->move_topic_button = str_replace(array('$title', '$link'), array(JText::_('Move topic'), $this->createRoute('view=topic&layout=move&id=' . $topic->id)), $this->forum->params['tmpl']['new_topic_button']); $this->delete_topic_button = $this->_createActionButton('delete', 'Delete topic', $topic->id, 'trash'); } $output = parent::display(); //@TODO move this to the controller $hit = KRequest::get('session.' . KFactory::get('admin::com.ninja.helper.default')->formid($topic->id), 'boolean'); if (!$hit && $topic->created_user_id != $me->id) { $topic->hit(); KRequest::set('session.' . KFactory::get('admin::com.ninja.helper.default')->formid($topic->id), true); } return $output; }
/** * */ public function setEmail($email) { if (KFactory::tmp('lib.koowa.filter.email')->validate($email)) { $this->email = $email; $this->properties['gravatar_id'] = md5(strtolower($this->email)); return true; } return false; }
/** * Filter the data, 'text' is a raw Column (because only administrators use this) */ public function filter($data) { settype($data, 'array'); //force to array if ($data['text']) { $this->getColumn('text')->filter = KFactory::tmp('lib.koowa.filter.raw'); } return parent::filter($data); }
public function display($tpl = null) { $model = KFactory::get('admin::com.nooku.model.translations'); $this->assign('data', $model->getStats()); $this->assign('languages', KFactory::get('admin::com.nooku.model.nooku')->getLanguages()); $this->assign('color', new NookuConfigColor()); $this->assign('table_name', KInput::get('table_name', 'get', KFactory::tmp('admin::com.nooku.filter.tablename'))); parent::display($tpl); }
public function importXml(SimpleXMLElement $xml) { parent::importXml($xml); foreach ($this->_xml->option as $option) { $elem = KFactory::tmp('admin::com.ninja.form.element.select.checkbox')->importXml($option); $this->addOption($elem); } return $this; }
public function getDefaultState() { $state = parent::getDefaultState(); $state['user_id'] = KInput::get('user_id', 'get', 'int', null, 0); $state['year'] = KInput::get('year', 'get', 'int', null, date('Y')); $state['month'] = KInput::get('month', 'get', 'digit', null, date('m')); $state['table_name'] = KInput::get('table_name', 'get', KFactory::tmp('admin::com.nooku.filter.tablename'), null, ''); return $state; }
public function __construct(KConfig $options) { parent::__construct($options); $napi = clone $this->getIdentifier(); $napi->package = 'ninja'; $identifier = $this->getIdentifier(); $this->_state->insert('limit', 'int', 0); KFactory::tmp('admin::com.ninja.helper.installer', array('identifier' => $napi)); KFactory::tmp('admin::com.ninja.helper.installer', array('identifier' => $identifier)); }
public function display() { $this->usergroup = $this->getModel()->getItem(); $objects = KFactory::get('admin::com.ninjaboard.permissions')->getObjects(); foreach ($objects as $object) { $names[] = 'com_ninjaboard.usergroup.' . $this->usergroup->id . '.' . $object; } $this->permissions = KFactory::tmp('admin::com.ninja.helper.access', array('name' => $names, 'id' => KFactory::get('admin::com.ninja.helper.default')->formid('permissions'), 'inputName' => 'permissions', 'inputId' => 'permissions', 'render' => 'usergroups', 'objects' => $objects)); return parent::display(); }
public function display() { $this->assign('params', KFactory::get('admin::com.ninjaboard.model.settings')->getParams()); if (KFactory::tmp('lib.joomla.user')->guest) { $this->mixin(KFactory::get('admin::com.ninja.view.user.mixin')); $this->setLoginLayout(); return parent::display(); } return parent::display(); }
/** * Import the sample content * * @return $this */ public function convert() { $tables = array(array('name' => 'attachments', 'options' => array('name' => 'ccb_attachments'), 'query' => KFactory::tmp('lib.koowa.database.query')->select(array('tbl.id', 'tbl.post_id AS post', 'tbl.real_name AS name', 'post.post_user AS joomla_user_id', 'tbl.ccb_name AS file'))->join('left', 'ccb_posts AS post', 'tbl.post_id = post.id')), array('name' => 'forums', 'options' => array('name' => 'ccb_category'), 'query' => KFactory::tmp('lib.koowa.database.query')->select(array('(id + (SELECT MAX(id) FROM #__ccb_forums)) AS id', 'cat_name AS title', "'/' AS path"))), array('name' => 'forums', 'options' => array('name' => 'ccb_forums'), 'query' => KFactory::tmp('lib.koowa.database.query')->select(array('id', 'forum_name AS title', 'forum_desc AS description', 'topic_count AS topics', 'post_count AS posts', 'last_post_id', 'published AS enabled', 'locked', "CONCAT('/', (cat_id + (SELECT MAX(id) FROM #__ccb_forums)), '/') AS path"))), array('name' => 'posts', 'options' => array('name' => 'ccb_posts'), 'query' => KFactory::tmp('lib.koowa.database.query')->select(array('*', 'topic_id AS ninjaboard_topic_id', 'post_subject AS subject', 'post_text AS text', 'post_user AS created_by', 'FROM_UNIXTIME(post_time) AS created_on', 'ip AS user_ip', 'modified_by', 'FROM_UNIXTIME(modified_time) AS mofidied_on', 'modified_reason AS edit_reason'))), array('name' => 'topics', 'options' => array('name' => 'ccb_topics'), 'query' => KFactory::tmp('lib.koowa.database.query')->select(array('*', 'reply_count AS replies', 'topic_type AS topic_type_id', 'start_post_id AS first_post_id'))), array('name' => 'people', 'options' => array('name' => 'ccb_users'), 'query' => KFactory::tmp('lib.koowa.database.query')->select(array('user_id AS id', 'signature', 'post_count AS posts', 'avatar')))); //This returns false if the import is big enough to be done in steps. //So we need to stop the importing in this step, in order for it to initiate if ($this->importData($tables, 'ccboard') === false) { return $this; } //Convert html 2 bbcode where needed if (isset($this->data['posts'])) { foreach ($this->data['posts'] as $id => $post) { if (!isset($this->data['posts'][$id]['text'])) { continue; } $this->data['posts'][$id]['text'] = html2bbcode($post['text']); } } //Move over file attachments if (isset($this->data['attachments'])) { foreach ($this->data['attachments'] as $id => $attachment) { $from = JPATH_ROOT . '/components/com_ccboard/assets/uploads/' . $attachment['file']; $file = JPATH_ROOT . '/media/com_ninjaboard/attachments/' . $attachment['file']; //Don't do anything if avatar don't exist if (!JFile::exists($from)) { continue; } JFile::copy($from, $file); } } //Move over avatars if (isset($this->data['people'])) { foreach ($this->data['people'] as $id => $person) { if (!$person['avatar']) { continue; } $from = JPATH_ROOT . '/components/com_ccboard/assets/avatar/' . $person['avatar']; $file = basename($from); $avatar = '/media/com_ninjaboard/images/avatars/' . $person['id'] . '/' . $file; //Don't do anything if avatar don't exist if (!JFile::exists($from)) { continue; } JFile::copy($from, JPATH_ROOT . $avatar); $this->data['people'][$id]['avatar'] = $avatar; } } //Clear cache folder so that avatars and attachments cache are cleared //@TODO this should only run once $cache = JPATH_ROOT . '/cache/com_ninjaboard/'; if (JFolder::exists($cache)) { JFolder::delete($cache); } parent::convert(); return $this; }
/** * Specialized in order to dynamically get the usergroups list when needed * * @TODO performance optimize this * * @param string The column name. */ public function __get($column) { if ($column == 'usergroups') { if (!isset($this->_usergroups)) { $user = KFactory::tmp('admin::com.ninjaboard.model.users')->id($this->created_by)->getItem(); $this->_usergroups = $user->usergroups; } return $this->_usergroups; } return parent::__get($column); }
/** * Import an XML form definition. * * @param SimpleXMLElement The form in XML format * @return NinjaFormAbstract */ public function importXml(SimpleXMLElement $xml) { $this->_xml = $xml; // Add each element to the form foreach ($this->_xml->children() as $name => $xmlElem) { $type = $name == 'element' ? (string) $xmlElem['type'] : 'admin::com.ninja.form.element.' . $name; $elem = KFactory::tmp($type)->importXml($xmlElem); $this->addElement($elem); } return $this; }
public function display() { $model = $this->getModel(); $forum = $model->getItem(); $this->_subtitle = $forum->title; if (!$forum->id) { if (KFactory::get('lib.joomla.user')->guest) { $this->mixin(KFactory::get('admin::com.ninja.view.user.mixin')); $this->setLoginLayout(); return parent::display(); } else { $this->title = JText::_("Access to this forum declined"); $this->msg = JText::_('Contact an administrator immidiatly if this is an mistake.'); JError::raiseError(404, JText::_('Forum not found')); return parent::display(); } } $model = KFactory::tmp('site::com.ninjaboard.model.forums')->limit(0)->sort('path_sort_ordering')->enabled(true)->recurse(1)->path($forum->id); $forums = $model->getList(); //@TODO optimize this in the model instead foreach ($forums as $row) { $rows = KFactory::tmp('site::com.ninjaboard.model.forums')->sort('path_sort_ordering')->enabled(true)->recurse(1)->path($row->id); if ($rows->getTotal() < 1) { continue; } $row->subforums = $rows->getList(); } $this->assign('forums', $forums); $this->limit = KRequest::get('get.limit', 'int', 10); $this->total = KFactory::tmp('site::com.ninjaboard.model.topics')->direction('desc')->sort('last_post_on')->forum($forum->id)->limit($this->limit)->offset(KRequest::get('get.offset', 'int', 0))->getTotal(); if ($this->total > 0) { $this->assign('topics', KFactory::get('site::com.ninjaboard.controller.topic')->setView(KFactory::get('site::com.ninjaboard.view.topics.html'))->direction('desc')->sort('last_post_on')->limit($this->limit)->offset(KRequest::get('get.offset', 'int', 0))->forum($forum->id)->layout('list')->display()); } else { $this->assign('topics', false); } $this->assign('pagination', KFactory::get('site::com.ninjaboard.template.helper.paginator', array('name' => 'topics'))->pagination($this->total, KRequest::get('get.offset', 'int', 0), $this->limit, 4)); if ($model->getTotal()) { ob_start(); echo $this->getTemplate()->loadIdentifier('site::com.ninjaboard.view.forum.block_subforums', $this->_data)->render(true); $this->assign('block_subforums', $this->render(ob_get_clean(), false, $forum->params['module'])); } else { $this->assign('block_subforums', false); } $me = KFactory::get('admin::com.ninjaboard.model.people')->getMe(); $this->watch_button = $me->id && $forum->params['email_notification_settings']['enable_email_notification']; $this->assign('me', $me); $this->new_topic_button = false; if (KFactory::get('lib.joomla.user')->guest || $forum->topic_permissions > 1 && $forum->post_permissions > 1) { $this->new_topic_button = '<div class="new-topic">' . str_replace(array('$title', '$link', '$class'), array(JText::_('New Topic'), $this->createRoute('view=post&forum=' . $forum->id), 'action-new'), $forum->params['tmpl']['new_topic_button']) . '</div>'; } $this->assign('toolbar', $this->new_topic_button); $this->setLayout('default'); return parent::display(); }
public function display() { // get module parameters $this->assign('messages', $this->params->get('messages', '1')); $this->assign('watches', $this->params->get('watches', '1')); $this->assign('profile', $this->params->get('profile', '1')); $this->assign('logout', $this->params->get('logout', '1')); $this->me = KFactory::get('site::com.ninjaboard.model.people')->getMe(); $this->profileurl = JRoute::_('index.php?option=com_ninjaboard&view=person&id=' . $this->me->id); $this->unread = (int) KFactory::tmp('site::com.ninjaboard.model.messages')->unread(1)->getTotal(); parent::display(); }
public function target($config = array()) { $config = new KConfig($config); $config->append(array('name' => 'stream_target_id', 'state' => null, 'attribs' => array())); $list = KFactory::tmp('admin::com.stream.model.targets')->getList(); $options = array(); $options[] = $this->option(array('value' => 0, 'text' => '- ' . JText::_('Select target') . ' -')); foreach ($list as $item) { $options[] = $this->option(array('value' => $item->id, 'text' => $item->title)); } $list = $this->optionlist(array('options' => $options, 'name' => $config->name, 'attribs' => $config->attribs, 'selected' => $config->selected)); return $list; }