/**
  * Test JModelAdmin::__construct
  *
  * @since   3.4
  *
  * @return  void
  *
  * @testdox Constructor applies configuration
  */
 public function testConstructorAppliesConfiguration()
 {
     $config = array('event_after_delete' => 'event_after_delete', 'event_after_save' => 'event_after_save', 'event_before_delete' => 'event_before_delete', 'event_before_save' => 'event_before_save', 'event_change_state' => 'event_change_state', 'text_prefix' => 'text_prefix');
     $this->object->__construct($config);
     // Check if config was applied correctly
     foreach ($config as $key => $value) {
         if ($key == "text_prefix") {
             $this->assertEquals(strtoupper($value), TestReflection::getValue($this->object, $key));
         } else {
             $this->assertEquals($value, TestReflection::getValue($this->object, $key));
         }
     }
 }
示例#2
0
 public function validate($form, $data, $group = null)
 {
     // Prepare the data.
     $data["level"] = implode(",", $data["level"]);
     return parent::validate($form, $data, $group);
     // TODO: Change the autogenerated stub
 }
示例#3
0
 public function getItem($pk = null)
 {
     if ($item = parent::getItem($pk)) {
         $item->assistance = $item->params['assistance'];
     }
     return $item;
 }
示例#4
0
 public function save($form)
 {
     $canDo = JoaktreeHelper::getActions();
     $msg = JText::_('JTAPPS_MESSAGE_NOSAVE');
     if ($canDo->get('core.create') || $canDo->get('core.edit')) {
         $ret = parent::save($form);
         if ($ret) {
             $msg = JText::_('JT_MESSAGE_SAVED');
         }
         // Bind the rules.
         if (isset($form['rules'])) {
             $actions = array();
             $tmp = array();
             $tmp[0] = '';
             foreach ($data['rules'] as $action => $identities) {
                 $identities = array_diff($identities, $tmp);
                 $actions[$action] = $identities;
             }
             $table = $this->getTable();
             $rules = new JRules($actions);
             $table->setRules($rules);
         }
     }
     return $msg;
 }
示例#5
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)
 {
     //debug::msg('model->getItem');
     if ($item = parent::getItem($pk)) {
     }
     return $item;
 }
示例#6
0
 function save($data)
 {
     $courses_csv = implode(',', $data['courses']);
     $data['courses'] = $courses_csv;
     $return = parent::save($data);
     return $return;
 }
示例#7
0
 /**
  * Method to get a category.
  *
  * @param	integer	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 JRegistry();
         $registry->loadJSON($result->metadata);
         $result->metadata = $registry->toArray();
         // Convert the created and modified dates to local user time for display in the form.
         jimport('joomla.utilities.date');
         $tz = new DateTimeZone(JFactory::getApplication()->getCfg('offset'));
         if (intval($result->created_time)) {
             $date = new JDate($result->created_time);
             $date->setTimezone($tz);
             $result->created_time = $date->toMySQL(true);
         } else {
             $result->created_time = null;
         }
         if (intval($result->modified_time)) {
             $date = new JDate($result->modified_time);
             $date->setTimezone($tz);
             $result->modified_time = $date->toMySQL(true);
         } else {
             $result->modified_time = null;
         }
     }
     return $result;
 }
示例#8
0
文件: service.php 项目: ngxuanmui/hp3
 public function save($data)
 {
     if (!empty($data['payment_type'])) {
         $data['payment_type'] = json_encode($data['payment_type']);
     }
     return parent::save($data);
 }
示例#9
0
 protected function prepareTable($table)
 {
     jimport('joomla.filter.output');
     $date = JFactory::getDate();
     $user = JFactory::getUser();
     parent::prepareTable($table);
 }
示例#10
0
 public function save($data)
 {
     $success = parent::save($data);
     if ($success) {
         // request option list
         $values = JRequest::getVar('joomdoc_option_value', array(), 'default', 'array');
         $labels = JRequest::getVar('joomdoc_option_label', array(), 'default', 'array');
         // prepare database table
         $option = JTable::getInstance('Option', JOOMDOC_TABLE_PREFIX);
         /* @var $option JoomDOCTableOption */
         $option->field = $this->getState($this->getName() . '.id');
         $option->ordering = 0;
         $query = $this->getDbo()->getQuery(true);
         $query->select('id')->from('#__joomdoc_option')->where('field = ' . (int) $option->field);
         $ids = $this->getDbo()->setQuery($query)->loadColumn();
         $sid = array();
         foreach ($values as $id => $value) {
             $option->id = in_array($id, $ids) ? $id : null;
             $option->value = $value;
             $option->label = $labels[$id];
             $option->ordering++;
             $option->store();
             $sid[] = (int) $option->id;
         }
         $query->clear()->delete('#__joomdoc_option')->where('field = ' . (int) $option->field);
         if ($sid) {
             $query->where('id NOT IN (' . implode(', ', $sid) . ')');
         }
         $this->getDbo()->setQuery($query)->query();
     }
     return $success;
 }
 /**
  * Method to get a single comment.
  *
  * @param   integer  $pk  The id of the primary key.
  *
  * @return  mixed  Object on success, false on failure.
  */
 public function getItem($pk = null)
 {
     if ($item = parent::getItem($pk)) {
         $item->content_id = (string) $item->content_id . ' - ' . $this->_getContentTitle($item->id);
     }
     return $item;
 }
示例#12
0
 public function getItem($pk = null)
 {
     $item = parent::getItem($pk);
     $item->selections = new Registry($item->selections);
     $item->selections = $item->selections->toArray();
     return $item;
 }
示例#13
0
 /**
  * Override delete method to add the image processing
  */
 public function delete(&$pks)
 {
     // standard joomla delete
     $delete = parent::delete($pks);
     if (!$delete) {
         return false;
     }
     // delete images
     $imageHelper = new CHPanelHelperImage(JComponentHelper::getParams('com_chpanel'));
     foreach ($pks as $pk) {
         // delete hotel image file
         $imageHelper->deleteImage($pk, 'hotels');
         // delete hotel gallery images
         $query_images = $this->_db->getQuery(true)->select('id')->from('#__chpanel_images')->where("`hotel_id` = " . (int) $pk);
         $images_ids = $this->_db->setQuery($query_images)->loadColumn();
         if (count($images_ids)) {
             // delete images files
             foreach ($images_ids as $image_id) {
                 $imageHelper->deleteImage($image_id, 'images');
             }
             // db delete images
             $query_delete_images = $this->_db->getQuery(true)->delete('#__chpanel_images')->where("`hotel_id` = " . (int) $pk);
             $this->_db->setQuery($query_delete_images)->query();
         }
     }
     // delete hotel translations
     $this->_db->setQuery("DELETE FROM `#__chpanel_translations` WHERE `hotel_id` IN(" . implode(',', $pks) . ")")->query();
     return true;
 }
示例#14
0
 /**
  * Auto-populate the model state.
  *
  * Note. Calling getState in this method will result in recursion.
  *
  * @return  void
  * @since    3.0
  */
 protected function preprocessForm(JForm $form, $data, $group = 'jevents')
 {
     // Association content items
     $app = JFactory::getApplication();
     $assoc = false && JLanguageAssociations::isEnabled() && JFactory::getApplication()->isAdmin();
     if ($assoc) {
         $languages = JLanguageHelper::getLanguages('lang_code');
         $addform = new SimpleXMLElement('<form />');
         $fields = $addform->addChild('fields');
         $fields->addAttribute('name', 'associations');
         $fieldset = $fields->addChild('fieldset');
         $fieldset->addAttribute('name', 'item_associations');
         $fieldset->addAttribute('description', 'COM_JEVENTS_ITEM_ASSOCIATIONS_FIELDSET_DESC');
         $add = false;
         foreach ($languages as $tag => $language) {
             if (empty($data->language) || $tag != $data->language) {
                 $add = true;
                 $field = $fieldset->addChild('field');
                 $field->addAttribute('name', $tag);
                 $field->addAttribute('type', 'modal_article');
                 $field->addAttribute('language', $tag);
                 $field->addAttribute('label', $language->title);
                 $field->addAttribute('translate_label', 'false');
                 $field->addAttribute('edit', 'true');
                 $field->addAttribute('clear', 'true');
             }
         }
         if ($add) {
             $form->load($addform, false);
         }
     }
     parent::preprocessForm($form, $data, $group);
 }
示例#15
0
 /**
  * Constructor
  *
  * @since 0.9
  */
 function __construct()
 {
     parent::__construct();
     $cid = JRequest::getVar('cid', array(0), '', 'array');
     JArrayHelper::toInteger($cid, array(0));
     $this->setId($cid[0]);
 }
示例#16
0
文件: route.php 项目: A-Bush/pprod
 /**
  * Clean the cache.
  * It also cleans the simplecustomrouter plugin cache, as the routes
  * configured by this component are used by that plugin.
  * 
  * This method is called when needed from parent models.
  * 
  * @param string $group The cache group
  * @param string $client_id The ID of the client
  */
 protected function cleanCache($group = null, $client_id = 0)
 {
     $conf = JFactory::getConfig();
     $options = array('defaultgroup' => 'simplecustomrouter', 'cachebase' => $conf->get('cache_path', JPATH_SITE . '/cache'));
     $cache = JCache::getInstance('', $options)->clean();
     parent::cleanCache($group, $client_id);
 }
示例#17
0
 /**
  * Prepare and sanitise the table data prior to saving
  *
  * @param  JTable  A JTable object
  */
 protected function prepareTable($table)
 {
     if (JFactory::getApplication()->input->get('task') == 'save2copy') {
         $table->keywords = JText::_('COM_TAGMETA_COPY_OF') . $table->keywords;
     }
     parent::prepareTable($table);
 }
 /**
  * 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)) {
         //Do any procesing on fields here if needed
     }
     return $item;
 }
示例#19
0
文件: list.php 项目: fracting/cmc
 /**
  * The save function
  *
  * @param   array  $list  - data to save
  *
  * @return bool
  */
 public function save($list)
 {
     $user = JFactory::getUser();
     $item = array();
     $item['id'] = null;
     $item['mc_id'] = $list['id'];
     $item['web_id'] = $list['web_id'];
     $item['list_name'] = $list['name'];
     $item['date_created'] = $list['date_created'];
     $item['email_type_option'] = $list['email_type_option'];
     $item['use_awesomebar'] = $list['use_awesomebar'];
     $item['default_from_name'] = $list['default_from_name'];
     $item['default_from_email'] = $list['default_from_email'];
     $item['default_subject'] = $list['default_subject'];
     $item['default_language'] = $list['default_language'];
     $item['list_rating'] = $list['list_rating'];
     $item['subscribe_url_short'] = $list['subscribe_url_short'];
     $item['subscribe_url_long'] = $list['subscribe_url_long'];
     $item['beamer_address'] = $list['beamer_address'];
     $item['visibility'] = $list['visibility'];
     $item['created_user_id'] = $user->id;
     $item['created_time'] = JFactory::getDate()->toSql();
     $item['modified_user_id'] = $user->id;
     $item['modified_time'] = JFactory::getDate()->toSql();
     $item['access'] = 1;
     $item['query_data'] = json_encode($list);
     return parent::save($item);
 }
示例#20
0
 public function __construct($config = array())
 {
     parent::__construct($config);
     $this->app = JFactory::getApplication();
     $this->me = KunenaUserHelper::getMyself();
     $this->config = KunenaFactory::getConfig();
 }
示例#21
0
 protected function populateState()
 {
     $addon_id = JFactory::getApplication()->input->getInt('addon_id');
     $this->setState($this->getName() . '.addon_id', $addon_id);
     // List state information.
     parent::populateState();
 }
示例#22
0
 public function getItem($pk = null)
 {
     if ($item = parent::getItem($pk)) {
         // Convert the params field to an array.
     }
     return $item;
 }
示例#23
0
 public function delete(&$pks)
 {
     $pks = (array) $pks;
     $dir = JPATH_ROOT . '/images/baforms/';
     $db = JFactory::getDBO();
     foreach ($pks as $pk) {
         $query = $db->getQuery(true);
         $id = $pk;
         $files = array();
         $query->select("mesage");
         $query->from("#__baforms_submissions");
         $query->where("id=" . $pk);
         $db->setQuery($query);
         $items = $db->loadResult();
         $items = explode('_-_', $items);
         foreach ($items as $item) {
             if ($item != '') {
                 $item = explode('|-_-|', $item);
                 if ($item[2] == 'upload') {
                     if ($item[1] != '') {
                         array_push($files, $item[1]);
                     }
                 }
             }
         }
         if (parent::delete($pk)) {
             foreach ($files as $file) {
                 unlink($dir . $file);
             }
         } else {
             return false;
         }
     }
     return true;
 }
示例#24
0
 protected function populateState()
 {
     parent::populateState();
     $this->setState('template.id', JRequest::getInt('id'));
     $this->setState('content.id', null);
     $this->setState('category.id', null);
 }
示例#25
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)
 {
     //debug::msg('model->getItem');
     if ($item = parent::getItem($pk)) {
         // Convert the params field to an array.
         /* 	$registry = new JRegistry;
                       $registry->loadString($item->attribs);
                       $item->attribs = $registry->toArray();
         
                       // Convert the metadata field to an array.
                       $registry = new JRegistry;
                       $registry->loadString($item->metadata);
                       $item->metadata = $registry->toArray();
         
                       // Convert the images field to an array.
                       $registry = new JRegistry;
                       $registry->loadString($item->images);
                       $item->images = $registry->toArray();
         
                       // Convert the urls field to an array.
                       $registry = new JRegistry;
                       $registry->loadString($item->urls);
                       $item->urls = $registry->toArray();
         
         
         
                       $item->articletext = trim($item->fulltext) != '' ? $item->introtext . "<hr id=\"system-readmore\" />" . $item->fulltext : $item->introtext;
                      * 
                      */
     }
     return $item;
 }
示例#26
0
 public function getItem($pk = null)
 {
     $item = parent::getItem($pk);
     if ($item->meal) {
         $item->meal = explode(';', $item->meal);
     }
     return $item;
 }
示例#27
0
文件: contag.php 项目: smhnaji/sdnet
 /**
  * Method to test whether a record can have its state edited.
  *
  * @param   object  $record  A record object.
  *
  * @return  boolean  True if allowed to change the state of the record. Defaults to the permission set in the component.
  *
  * @since   1.6
  */
 protected function canEditState($record)
 {
     $permissions = SibdietHelper::getUserPermissions();
     if (in_array('contags', $permissions)) {
         return parent::canEditState($record);
     }
     return false;
 }
示例#28
0
 function __construct($config)
 {
     parent::__construct();
     $this->option = JOOMDOC_OPTION;
     $this->name = $this->getName();
     $this->setState($this->getName() . '.id', JRequest::getInt('id'));
     $this->checkin();
 }
示例#29
0
 function __construct()
 {
     parent::__construct();
     if (!class_exists('TableItinerary')) {
         AImporter::table('itinerary');
     }
     $this->_table = $this->getTable('itinerary');
 }
示例#30
0
 /**
  * Stock method to auto-populate the model state.
  * @return  void
  * @since   12.2
  */
 protected function populateState()
 {
     parent::populateState();
     $app = JFactory::getApplication();
     /** @var $app JApplicationAdministrator * */
     $value = $app->getUserStateFromRequest("url.id", "url_id");
     $this->setState($this->getName() . '.url_id', $value);
 }