Exemple #1
0
 function save($data)
 {
     $oldData = array();
     if ($data['id'] > 0) {
         $table = $this->getTable();
         $table->load($data['id']);
         $oldData['id'] = $table->id;
         $oldData['provider'] = $table->provider;
         $oldData['type'] = $table->type;
         $oldData['attribs'] = (array) $table->attribs;
     }
     // Set the dates
     $date = JFactory::getDate();
     if ($data['id'] == 0) {
         $data['created'] = $date->toSql();
     }
     $data['modified'] = $date->toSql();
     if ($data['provider'] != '--' && $data['type'] != '--') {
         $channel = JFBCFactory::provider($data['provider'])->channel($data['type']);
         $data = $channel->onBeforeSave($data);
         // Manipulate the data however may be necessary
     }
     $return = parent::save($data);
     // Used to removed permissions from users that aren't associated with this channel (or anything else needed for cleanup)
     if ($return && $data['provider'] != '--' && $data['type'] != '--') {
         $data['id'] = $this->getState('channel.id');
         $channel->onAfterSave($data, $oldData);
     }
     return $return;
 }
Exemple #2
0
 /**
  * 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);
 }
Exemple #3
0
 public function save($data)
 {
     if (!empty($data['payment_type'])) {
         $data['payment_type'] = json_encode($data['payment_type']);
     }
     return parent::save($data);
 }
Exemple #4
0
 function save($data)
 {
     $courses_csv = implode(',', $data['courses']);
     $data['courses'] = $courses_csv;
     $return = parent::save($data);
     return $return;
 }
Exemple #5
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;
 }
Exemple #6
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;
 }
Exemple #7
0
 public function save($data)
 {
     if (parent::save($data)) {
         $formId = $this->getState($this->getName() . '.id');
         $db = JFactory::getDBO();
         $query = 'DELETE  FROM `#__baforms_columns` WHERE `form_id`=' . $formId;
         $db->setQuery($query);
         $db->query();
         $query = 'DELETE  FROM `#__baforms_items` WHERE `form_id`=' . $formId;
         $db->setQuery($query);
         $db->query();
         $newdata = explode('|', $data['form_columns']);
         foreach ($newdata as $dat) {
             if ($dat != '') {
                 $table = JTable::getInstance('Columns', 'FormsTable');
                 $table->bind(array('form_id' => $formId, 'settings' => $dat));
                 $table->store();
             }
         }
         $newdata = explode('|_-_|', $data['form_content']);
         foreach ($newdata as $dat) {
             if ($dat != '') {
                 $table = JTable::getInstance('Items', 'FormsTable');
                 $table->bind(array('form_id' => $formId, 'column_id' => '2', 'settings' => $dat));
                 $table->store();
             }
         }
         return true;
     } else {
         return false;
     }
 }
Exemple #8
0
 public function save($data)
 {
     //$data['begin'] = sprintf("%u", ip2long(long2ip(ip2long($data['begin']))));
     //$data['end'] = sprintf("%u", ip2long(long2ip(ip2long($data['end']))));
     $data['begin'] = sprintf("%010u", ip2long($data['begin']));
     $data['end'] = sprintf("%010u", ip2long($data['end']));
     parent::save($data);
 }
Exemple #9
0
 public function save($data)
 {
     if (parent::save($data)) {
         $this->updateCounter();
         return true;
     } else {
         return false;
     }
 }
Exemple #10
0
 public function save($data)
 {
     $app = JFactory::getApplication();
     if ($app->input->get('task') == 'save' || $app->input->get('task') == "apply") {
         $object->type = $data['type'];
         $object->unit = $data['unit'];
         $data['params'] = json_encode($object);
     }
     return parent::save($data);
 }
 /**
  * Method to save the form data.
  *
  * @param   array  $data  The form data.
  *
  * @return  boolean  True on success, False on error.
  *
  * @since   12.2
  */
 public function save($data)
 {
     if (isset($data['alias']) && empty($data['alias'])) {
         /** @noinspection PhpUndefinedClassInspection */
         $data['alias'] = ru_RULocalise::transliterate($data['manufacturer_name']);
         $data['alias'] = preg_replace('#\\W#', '-', $data['alias']);
         $data['alias'] = preg_replace('#[-]+#', '-', $data['alias']);
     }
     return parent::save($data);
 }
Exemple #12
0
 /**
  * Method to save the form data.
  *
  * @param   array  $data  The form data.
  *
  * @return  boolean  True on success.
  *
  * @since    3.0
  */
 public function save($data)
 {
     /*		echo '<pre>';
     			print_r($data);
     		echo '</pre>';
     
     		exit();*/
     parent::save($data);
     return true;
 }
Exemple #13
0
 public function save($data)
 {
     $app = JFactory::getApplication();
     if ($app->input->get('task') == 'save2copy') {
         list($title, $alias) = $this->pageGenerateNewTitle($data['alias'], $data['title']);
         $data['title'] = $title;
         $data['alias'] = $alias;
     }
     parent::save($data);
     return true;
 }
 public function save($data)
 {
     $app = JFactory::getApplication();
     $param = $app->input->get('params', array(), 'array');
     $item = $this->getItem($data['id']);
     $params = (object) $item->params;
     $params->flight_number = $param['flight_number'];
     $params->return_flight_number = $param['return_flight_number'];
     $data['params'] = json_encode($params);
     return parent::save($data);
 }
 public function save($data)
 {
     $app = JFactory::getApplication();
     if ($app->input->get('task') == 'save' || $app->input->get('task') == "apply") {
         $jfom = $app->input->get('jform', array(), 'array');
         $params = array();
         $params['price_per_distance'] = $jfom['price_per_distance'];
         $data['params'] = json_encode($params);
     }
     return parent::save($data);
 }
 public function save($data)
 {
     $app = JFactory::getApplication();
     // Alter the title for save as copy
     if ($app->input->get('task') == 'save' || $app->input->get('task') == "apply") {
         $post = $app->input->get('jform', array(), 'array');
         $data['email_admin_body'] = $post['email_admin_body'];
         $data['email_customer_body'] = $post['email_customer_body'];
         $data['email_payment_body'] = $post['email_payment_body'];
     }
     return parent::save($data);
 }
Exemple #17
0
 public function save($data)
 {
     $result = $this->addAddress($data['label']);
     if (is_array($result)) {
         $data['label'] = $result['label'];
         $data['address'] = $result['address'];
     } else {
         return false;
     }
     parent::save($data);
     return true;
 }
Exemple #18
0
 public function save($data)
 {
     if ($data['rss_authentication'] == 2) {
         $data['rss_authentication_items'] = implode(',', $data['rss_authentication_group']);
     }
     if ($data['rss_type'] == 1) {
         $data['rss_type_items'] = implode(',', $data['rss_type_category']);
     }
     if ($data['rss_type'] == 2) {
         $data['rss_type_items'] = implode(',', $data['rss_type_license']);
     }
     return parent::save($data);
 }
Exemple #19
0
 public function save($data)
 {
     if (empty($data['automailing_type']) && !empty($data['automailing_event'])) {
         switch ($data['automailing_event']) {
             case 'date':
                 $data['automailing_type'] = 'scheduled';
                 break;
             case 'subscription':
                 $data['automailing_type'] = 'eventbased';
                 break;
         }
     }
     return parent::save($data);
 }
Exemple #20
0
 public function save($data)
 {
     if (isset($data['categories_assignment']) && count($data['categories_assignment'])) {
         $categoriesAssignment = $data['categories_assignment'];
         unset($data['categories_assignment']);
     }
     if (parent::save($data)) {
         $db = $this->getDbo();
         // Assign categories with this group;
         if (!empty($categoriesAssignment) && count($categoriesAssignment)) {
             $id = (int) $this->getState($this->getName() . '.id');
             // Update the mapping for category items that this field's group IS assigned to.
             $query = $db->getQuery(true)->update('#__tz_portfolio_plus_categories')->set('groupid = ' . $id)->where('id IN (' . implode(',', $categoriesAssignment) . ')')->where('groupid != ' . $id);
             $db->setQuery($query);
             $db->execute();
             $query = $db->getQuery(true);
             $query->select('id');
             $query->from($db->quoteName('#__tz_portfolio_plus_categories'));
             $query->where($db->quoteName('id') . ' IN(' . implode(',', $categoriesAssignment) . ')');
             $db->setQuery($query);
             if (!($updateIds = $db->loadColumn())) {
                 $updateIds = array();
             }
             // Insert category items with this template if they were created in com_content
             if ($insertIds = array_diff($categoriesAssignment, $updateIds)) {
                 $query = $db->getQuery(true);
                 $query->insert($db->quoteName('#__tz_portfolio_plus_categories'));
                 $query->columns('id,groupid');
                 foreach ($insertIds as $cid) {
                     $query->values($cid . ',0,' . $id);
                 }
                 $db->setQuery($query);
                 $db->execute();
             }
         }
         // Remove field's groups mappings for category items this style is NOT assigned to.
         // If unassigned then all existing maps will be removed.
         $query = $db->getQuery(true)->update('#__tz_portfolio_plus_categories')->set('groupid = 0');
         if (!empty($categoriesAssignment) && count($categoriesAssignment)) {
             $query->where('id NOT IN (' . implode(',', $categoriesAssignment) . ')');
         }
         $query->where('groupid = ' . $id);
         $db->setQuery($query);
         $db->execute();
         return true;
     }
     return true;
 }
 public function save($data)
 {
     if (parent::save($data)) {
         $assoc = JLanguageAssociations::isEnabled();
         if ($assoc) {
             $id = (int) $this->getState($this->getName() . '.id');
             $item = $this->getItem($id);
             // Adding self to the association
             $associations = $data['associations'];
             foreach ($associations as $tag => $id) {
                 if (empty($id)) {
                     unset($associations[$tag]);
                 }
             }
             // Detecting all item menus
             $all_language = $item->language == '*';
             if ($all_language && !empty($associations)) {
                 JError::raiseNotice(403, JText::_('COM_AUTHORLIST_ERROR_ALL_LANGUAGE_ASSOCIATED'));
             }
             $associations[$item->language] = $item->id;
             // Deleting old association for these items
             $db = JFactory::getDbo();
             $query = $db->getQuery(true)->delete('#__associations')->where('context=' . $db->quote('com_authorlist.author'))->where('id IN (' . implode(',', $associations) . ')');
             $db->setQuery($query);
             $db->execute();
             if ($error = $db->getErrorMsg()) {
                 $this->setError($error);
                 return false;
             }
             if (!$all_language && count($associations)) {
                 // Adding new association for these items
                 $key = md5(json_encode($associations));
                 $query->clear()->insert('#__associations');
                 foreach ($associations as $id) {
                     $query->values($id . ',' . $db->quote('com_authorlist.author') . ',' . $db->quote($key));
                 }
                 $db->setQuery($query);
                 $db->execute();
                 if ($error = $db->getErrorMsg()) {
                     $this->setError($error);
                     return false;
                 }
             }
         }
         return true;
     }
     return false;
 }
Exemple #22
0
 public function save($data)
 {
     $db = JFactory::getDBO();
     parent::save($data);
     $field_id = $this->getState($this->getName() . '.id', 'id');
     $db->setQuery("SHOW COLUMNS FROM #__rsmembership_subscribers WHERE `Field` = 'f" . $field_id . "'");
     if (!$db->loadResult()) {
         $type = 'VARCHAR(255)';
         if (in_array($data['type'], array('freetext', 'textarea'))) {
             $type = 'TEXT';
         }
         $db->setQuery("ALTER TABLE #__rsmembership_subscribers ADD `f" . $field_id . "` " . $type . " NOT NULL");
         $db->query();
     }
     return true;
 }
Exemple #23
0
 /**
  * save the imagetypeset
  *
  * @param array $data
  * @return bool|void
  */
 public function save($data)
 {
     $result = parent::save($data);
     if ($result === false) {
         return $result;
     }
     $id = $data['id'];
     if ($id == 0) {
         $id = $this->getState('imagetypeset.id');
     }
     $default_imagetypeid = $data['imagetypesdefault'];
     $db = JFactory::getDBO();
     $query = $db->getQuery(true);
     $query->delete('#__eventgallery_imagetypeset_imagetype_assignment');
     $query->where('imagetypesetid = ' . $db->quote($id));
     $db->setQuery($query);
     $db->execute();
     if (count($data['imagetypes']) > 0) {
         $db = JFactory::getDBO();
         $query = $db->getQuery(true);
         $query->insert('#__eventgallery_imagetypeset_imagetype_assignment');
         $query->columns('imagetypesetid, imagetypeid, ordering');
         foreach ($data['imagetypes'] as $i => $imagetypeid) {
             $query->values($db->quote($id) . ',' . $db->quote($imagetypeid) . ',' . $i);
         }
         $db->setQuery($query);
         $db->execute();
         $db = JFactory::getDBO();
         $query = $db->getQuery(true);
         $query->update('#__eventgallery_imagetypeset_imagetype_assignment');
         $query->set($db->quoteName('default') . ' = 0');
         $query->where('imagetypesetid = ' . $db->quote($id));
         $db->setQuery($query);
         $db->execute();
         $db = JFactory::getDBO();
         $query = $db->getQuery(true);
         $query->update('#__eventgallery_imagetypeset_imagetype_assignment');
         $query->set($db->quoteName('default') . ' = 1');
         $query->where('imagetypeid=' . $db->quote($default_imagetypeid));
         $query->where('imagetypesetid = ' . $db->quote($id));
         $db->setQuery($query);
         $db->execute();
     }
     return true;
 }
Exemple #24
0
 public function save($data)
 {
     $field = null;
     if (isset($data['id']) && $data['id']) {
         $field = $this->getItem($data['id']);
     }
     $success = parent::save($data);
     // If the options have changed delete the values
     if ($success && $field && isset($data['fieldparams']['options']) && isset($field->fieldparams['options'])) {
         $oldParams = json_decode($field->fieldparams['options']);
         $newParams = json_decode($data['fieldparams']['options']);
         if (count(array_intersect($oldParams->key, $newParams->key)) != count($oldParams->key)) {
             $this->_db->setQuery('delete from #__dpfields_fields_values where field_id = ' . (int) $field->id . ' and value not in (\'' . implode("','", $newParams->key) . '\')');
             $this->_db->query();
         }
     }
     return $success;
 }
Exemple #25
0
 /**
  * Override save method to add the image processing
  */
 public function save($data)
 {
     // perform default save
     $save = parent::save($data);
     if (!$save) {
         return false;
     }
     // save or delete image
     $imageHelper = new CHPanelHelperImage(JComponentHelper::getParams('com_chpanel'));
     $file = $_FILES['image'];
     if ($file['size']) {
         $imageHelper->uploadImage($file, $this->getState('room.id'), 'rooms');
     } else {
         if (JRequest::getInt('image_delete')) {
             $imageHelper->deleteImage($this->getState('room.id'), 'rooms');
         }
     }
     return true;
 }
Exemple #26
0
 /**
  * {@inheritdoc}
  *
  * @param   array $data Data to save
  *
  * @return bool
  *
  * @throws Exception
  */
 public function save($data)
 {
     // If groups data has been saved, let's assign translation method
     if (parent::save($data)) {
         $db = JFactory::getDbo();
         $query = $db->getQuery(true);
         $workingLanguage = NenoHelper::getWorkingLanguage();
         $groupId = (int) $this->getState($this->getName() . '.id');
         $query->delete('#__neno_content_element_groups_x_translation_methods')->where(array('group_id = ' . $groupId));
         $languages = array($workingLanguage);
         if (!empty($data['languages'])) {
             $languages = array_merge($data['languages'], $languages);
         }
         $query->where('lang IN (' . implode(',', $db->quote($languages)) . ')');
         $db->setQuery($query);
         $db->execute();
         $query->clear()->insert('#__neno_content_element_groups_x_translation_methods')->columns(array('group_id', 'lang', 'translation_method_id', 'ordering'));
         $insert = false;
         if (!empty($data['translation_methods'])) {
             $ordering = 1;
             foreach ($data['translation_methods'] as $translationMethodId) {
                 if (!empty($translationMethodId)) {
                     $insert = true;
                     foreach ($languages as $language) {
                         $query->values($groupId . ',' . $db->quote($language) . ',' . $db->quote($translationMethodId) . ', ' . $ordering);
                     }
                     $ordering++;
                 }
             }
         }
         if ($insert) {
             $db->setQuery($query);
             $db->execute();
         }
         NenoHelperBackend::consolidateTranslationMethods($groupId, empty($data['translation_methods']) || $data['translation_methods'][0] == 0);
         return true;
     }
     return false;
 }
Exemple #27
0
 public function save($data)
 {
     $savestate = parent::save($data);
     if ($savestate) {
         $relationTable = $this->getTable('OrgraphProjUser');
         $savestate = $relationTable->updateRelation($data['user_id'], $data['proj_ids']);
         if ($savestate) {
             jimport('joomla.filesystem.file');
             $avatarPath = JPATH_COMPONENT_SITE . DS . 'files' . DS;
             $mapfunc = function ($i) {
                 return $i['avatar'];
             };
             $file = array_map($mapfunc, JRequest::getVar('jform', null, 'files', 'array'));
             if ($file['error'] == 0) {
                 $filename = JFile::makeSafe($file['name']);
                 $src = $file['tmp_name'];
                 $srcext = strtolower(JFile::getExt($filename));
                 if (($srcext == 'png' || $srcext == 'jpg' || $srcext == 'jpeg') && $file['size'] <= 1048576) {
                     $userTable = $this->getTable('OrgraphUser');
                     $origin = $userTable->getAvatar($data['user_id']);
                     if (!empty($origin)) {
                         JFile::delete($avatarPath . $origin);
                     }
                     if (JFile::upload($src, $avatarPath . $filename)) {
                         $userTable->setAvatar($data['user_id'], $filename);
                         $savestate = true;
                     } else {
                         $savestate = false;
                     }
                 } else {
                     $savestate = false;
                 }
             }
         }
     }
     return $savestate;
 }
Exemple #28
0
 /**
  * Override save method to add tag translations
  */
 public function save($data)
 {
     // perform default save
     $save = parent::save($data);
     if (!$save) {
         return false;
     }
     // delete current translations
     $tag_id = $this->getState('tag.id');
     $this->_db->setQuery("DELETE FROM #__jkit_translations WHERE `ref_table` = 'tags' AND `ref_id` = {$tag_id}")->query();
     // get the language
     $table = $this->getTable();
     $table->load($tag_id);
     // store translations
     if ($table->language != '*') {
         // prepare data
         $langs = JKitHelperLangs::getLangs();
         $values = array();
         foreach ($langs as $lang) {
             // get translations preventing tag own language transaltion
             if (JRequest::getString('translation_title_' . $lang->lang_code) && $lang->lang_code != $table->language) {
                 $title = JRequest::getString('translation_title_' . $lang->lang_code);
                 $alias = JRequest::getString('translation_alias_' . $lang->lang_code);
                 if (!$alias) {
                     $alias = $title;
                 }
                 $safe_alias = JApplication::stringURLSafe($alias);
                 $values[] = "('tags', {$tag_id}, " . $this->_db->quote($lang->lang_code) . ", " . $this->_db->quote($title) . ", " . $this->_db->quote($safe_alias) . ")";
             }
         }
         // insert translations
         if (count($values)) {
             $this->_db->setQuery('INSERT INTO #__jkit_translations (ref_table, ref_id, lang, title, alias) VALUES ' . implode(',', $values))->query();
         }
     }
     return true;
 }
Exemple #29
0
 public function save($data)
 {
     $db = JFactory::getDBO();
     $query = $db->getQuery(true);
     if (empty($data['id'])) {
         $data['date_added'] = RSMembershipHelper::showDate(time(), 'Y-m-d H:i:s');
     }
     parent::save($data);
     $coupon_id = $this->getState($this->getName() . '.id', 'id');
     // delete
     $query->delete()->from($db->qn('#__rsmembership_coupon_items'))->where($db->qn('coupon_id') . ' = ' . $db->q($coupon_id));
     $db->setQuery($query);
     $db->execute();
     // insert in coupon_items
     if (!empty($data['used_for'])) {
         foreach ($data['used_for'] as $membership_item) {
             $query->clear();
             $query->insert($db->qn('#__rsmembership_coupon_items'))->set($db->qn('coupon_id') . ' = ' . $db->q($coupon_id) . ', ' . $db->qn('membership_id') . ' = ' . $db->q($membership_item));
             $db->setQuery($query);
             $db->execute();
         }
     }
     return true;
 }
Exemple #30
0
 /**
  * Extend save method to add the image and tag processing
  */
 public function save($data)
 {
     // joomla save
     $save = parent::save($data);
     if (!$save) {
         return false;
     }
     // get the hotel id
     $hotel_id = $this->getState('hotel.id');
     if (!$hotel_id) {
         return false;
     }
     // save or delete image
     $imageHelper = new CHPanelHelperImage(JComponentHelper::getParams('com_chpanel'));
     $file = $_FILES['image'];
     if ($file['size']) {
         $imageHelper->uploadImage($file, $hotel_id, 'hotels');
     } else {
         if (JRequest::getInt('image_delete')) {
             $imageHelper->deleteImage($hotel_id, 'hotels');
         }
     }
     return true;
 }