Exemplo n.º 1
0
 function saveIFrame()
 {
     $errors = array();
     $id = $this->save($errors);
     $helper = new JAVoiceHelpers();
     $objects = array();
     if ($id) {
         $objects[] = $helper->parseProperty("reload", "#reload" . $item->id, 1);
         $message[] = JText::_("SAVE_DATA_SUCCESSFULLY");
         $objects[] = $helper->parseProperty("html", "#system-message", $helper->message(0, $message));
     } else {
         $objects[] = $helper->parseProperty("html", "#system-message", $helper->message(1, $errors));
     }
     $helper = new JAVoiceHelpers();
     echo $helper->parse_JSON_new($objects);
     exit;
 }
Exemplo n.º 2
0
 function save()
 {
     global $javconfig;
     $model = $this->getModel('tags');
     $post["name"] = JRequest::getVar("name", "");
     $post["published"] = JRequest::getInt("published", 1);
     $post["id"] = JRequest::getInt("id", 0);
     if (strlen($post["name"]) < $javconfig["systems"]->get("tag_minimum_length", 10)) {
         $helper = new JAVoiceHelpers();
         $errors = JText::_("LENG_OF_TAG") . " '" . $post["name"] . "' " . JText::_("IS_VERY_SHORT");
         $objects[] = $helper->parseProperty("-javmsg-", "alert", $errors);
         $helper = new JAVoiceHelpers();
         echo $helper->parse_JSON_new($objects);
         exit;
     } else {
         if (strlen($post["name"]) > $javconfig["systems"]->get("tag_maximum_length", 100)) {
             $helper = new JAVoiceHelpers();
             $errors = JText::_("LENG_OF_TAG") . " '" . $post["name"] . "' " . JText::_("IS_VERY_LONG");
             $objects[] = $helper->parseProperty("-javmsg-", "alert", $errors);
             $helper = new JAVoiceHelpers();
             echo $helper->parse_JSON_new($objects);
             exit;
         } else {
             $model = $this->getModel('tags');
             if ($model->checkExistTag($post["name"], $post["id"])) {
                 $helper = new JAVoiceHelpers();
                 $errors = JText::_("TAG_NAME_ALREADY_EXIST");
                 $objects[] = $helper->parseProperty("-javmsg-", "alert", $errors);
                 $helper = new JAVoiceHelpers();
                 echo $helper->parse_JSON_new($objects);
                 exit;
             }
             $model->save($post);
         }
     }
 }
Exemplo n.º 3
0
 function saveIFrame()
 {
     $post = JRequest::get('request', JREQUEST_ALLOWHTML);
     $number = $post['number'];
     $errors = array();
     $id = $this->save($errors);
     $helper = new JAVoiceHelpers();
     $objects = array();
     if ($id) {
         $model = $this->getModel('forums');
         $item = $model->getItem();
         if ($post['id'] == '0') {
             $objects[] = $helper->parseProperty("reload", "#reload" . $item->id, 1);
         } else {
             $objects[] = $helper->parseProperty("html", "#system-message", $helper->message(0, JText::_("SAVE_DATA_SUCCESSFULLY")));
         }
         $objects[] = $helper->parseProperty("html", "#title" . $item->id, $item->title);
         $objects[] = $helper->parsePropertyPublish("html", "#publish" . $item->id, $item->published, $number);
         $modelvoicetypes = JAVBModel::getInstance('voicetypes', 'javoiceModel');
         $where = " AND ft.forums_id = {$item->id}";
         $joins = " INNER JOIN #__jav_forums_has_voice_types as ft ON t.id = ft.voice_types_id";
         $voicetypes = $modelvoicetypes->getDyamicItems($where, 't.title', 0, 0, 't.title', $joins);
         $strVoice = '';
         if ($voicetypes) {
             $strVoice = implode(", ", $voicetypes);
         }
         $item->strvoice = $strVoice;
         $objects[] = $helper->parseProperty("html", "#voice-types-" . $item->id, $item->strvoice);
         $objects[] = $helper->parseProperty("value", "#order" . $item->id, $item->ordering);
         //$objects [] = $helper->parsePropertyPublisha ( $item->id, $item->published );
     } else {
         $objects[] = $helper->parseProperty("html", "#system-message", $helper->message(1, $errors));
     }
     $helper = new JAVoiceHelpers();
     echo $helper->parse_JSON_new($objects);
     exit;
 }
Exemplo n.º 4
0
 function save($post, $noRedirect = 0)
 {
     global $javconfig;
     $mainframe = JFactory::getApplication();
     $row = $this->getTable('Tags', 'Table');
     $name = JRequest::getVar("name", '');
     if ($javconfig["systems"]->get("tag_to_be_lower_case", 0)) {
         $name = strtolower($name);
     }
     $publish = JRequest::getVar("published", 1);
     if ($post) {
         if ($javconfig["systems"]->get("tag_to_be_lower_case", 0)) {
             $post["name"] = strtolower($post["name"]);
         }
         $post["name"] = trim($post["name"]);
         if (!$row->bind($post)) {
             $mainframe->redirect('index.php?option=com_javoice&view=tags', $row->getError(), 'error');
         }
     } else {
         if (!JRequest::get('post')) {
             if ($this->checkExistTag($name)) {
                 if ($noRedirect == 0) {
                     $k++;
                     $object[$k] = new stdClass();
                     $object[$k]->id = '#system-message';
                     $object[$k]->attr = 'html';
                     $object[$k]->content = $errors;
                     $helper = new JAVoiceHelpers();
                     echo $helper->parse_JSON_new($object);
                     exit;
                 }
             }
             $post["name"] = $name;
             $post["publish"] = $publish;
             $post["name"] = trim($post["name"]);
             if (!$row->bind($post)) {
                 $mainframe->redirect('index.php?option=com_javoice&view=tags', $row->getError(), 'error');
             }
         } else {
             if (!$row->bind(JRequest::get('post'))) {
                 $mainframe->redirect('index.php?option=com_javoice&view=tags', $row->getError(), 'error');
             }
         }
     }
     if (!$row->check()) {
         $mainframe->redirect('index.php?option=com_javoice&view=tags&cid=' . $row->id, $row->getError(), 'error');
     }
     if (!$row->store()) {
         $mainframe->redirect('index.php?option=com_javoice&view=tags', $row->getError(), 'error');
     }
     $cache = JFactory::getCache('com_javoice');
     $cache->clean();
     if ($noRedirect) {
         return $row->id;
     }
     $helper = new JAVoiceHelpers();
     $errors = JText::_("TAG_SAVED");
     $objects[] = $helper->parseProperty("html", "#system-message", $errors);
     $objects[] = $helper->parseProperty("reload", "#reload" . 1, 1);
     $helper = new JAVoiceHelpers();
     echo $helper->parse_JSON_new($objects);
     exit;
 }
Exemplo n.º 5
0
 function saveIFrame()
 {
     $post = JRequest::get('request');
     $number = $post['number'];
     $errors = array();
     $id = $this->save($errors);
     $helper = new JAVoiceHelpers();
     $objects = array();
     if (count($errors) == 0) {
         $model = $this->getModel('voicetypes');
         $item = $model->getItem($id);
         if ($post['id'] == '0') {
             $objects[] = $helper->parseProperty("reload", "#reload" . $item->id, 1);
         } else {
             $objects[] = $helper->parseProperty("html", "#system-message", $helper->message(0, JText::_("SAVE_DATA_SUCCESSFULLY")));
         }
         $objects[] = $helper->parseProperty("html", "#title" . $item->id, $item->title);
         $objects[] = $helper->parsePropertyPublish("html", "#publish" . $item->id, $item->published, $number);
         if ($item->total_votes < 0) {
             $item->total_votes = JText::_("UNLIMITED");
         }
         $objects[] = $helper->parseProperty("html", "#total_votes" . $item->id, $item->total_votes);
         $objects[] = $helper->parseProperty("value", "#order" . $item->id, $item->ordering);
     } else {
         $objects[] = $helper->parseProperty("html", "#system-message", $helper->message(1, $errors));
     }
     $helper = new JAVoiceHelpers();
     echo $helper->parse_JSON_new($objects);
     exit;
 }
Exemplo n.º 6
0
 function saveAddUser()
 {
     $result = TRUE;
     $helper = new JAVoiceHelpers();
     $objects = array();
     $model = $this->getModel('configs');
     $data = $model->getItems();
     $item = JTable::getInstance('configs', 'Table');
     $item->bind($data);
     $data = $item->data;
     $params = class_exists('JRegistry') ? new JRegistry($data) : new JParameter($data);
     $group = JRequest::getVar('group', NULL);
     if (!$group) {
         $result = FALSE;
     }
     if ($result) {
         $cid = JRequest::getVar('cid', array(0), '', 'array');
         $user_id = '';
         $cids = array();
         if ($cid) {
             $cids[] = implode(',', $cid);
         }
         if ($params->get('permissions', '') != '') {
             $cids[] = $params->get('permissions', '');
         }
         if ($cids) {
             $user_id = implode(',', $cids);
         }
         $params->set('permissions', $user_id);
         $item->group = $group;
         $item->data = $params->toString();
         if ($item->store()) {
             $objects[] = $helper->parseProperty("reload", "#reload" . $item->id, 1);
             $message[] = JText::_("SAVE_DATA_SUCCESSFULLY");
             $objects[] = $helper->parseProperty("html", "#system-message", $helper->message(0, $message));
         } else {
             $message[] = JText::_("ERROR_OCCURRED_DATA_NOT_SAVED");
             $objects[] = $helper->parseProperty("html", "#system-message", $helper->message(1, $message));
         }
     } else {
         $message[] = JText::_("ERROR_OCCURRED_DATA_NOT_SAVED");
         $objects[] = $helper->parseProperty("html", "#system-message", $helper->message(1, $message));
     }
     $helper = new JAVoiceHelpers();
     echo $helper->parse_JSON_new($objects);
     exit;
 }
Exemplo n.º 7
0
 function saveIFrame()
 {
     $post = JRequest::get('request');
     $number = $post['number'];
     $errors = array();
     $reload = 0;
     $id = $this->save($errors, $reload);
     $helper = new JAVoiceHelpers();
     $objects = array();
     if ($id) {
         $model = $this->getModel('voicetypesstatus');
         $modelvoicetype = $this->getModel('voicetypes');
         $item = $model->getItem($id);
         $voicetype = $modelvoicetype->getItem($item->voice_types_id);
         if ($post['id'] == '0') {
             $objects[] = $helper->parseProperty("reload", "#reload" . $item->id, 1);
         } else {
             $objects[] = $helper->parseProperty("html", "#system-message", $helper->message(0, JText::_("SAVE_DATA_SUCCESSFULLY")));
         }
         $objects[] = $helper->parseProperty("html", "#title" . $item->id, $item->title);
         $objects[] = $helper->parseProperty("val", "#voice_types_id", $item->voice_types_id);
         $objects[] = $helper->parseProperty("reload", "#reload" . $item->id, $reload);
         $objects[] = $helper->parseProperty("html", "#vtitle" . $item->id, $voicetype->title);
         $objects[] = $helper->parseProperty("style", "#class_css" . $item->id, "background:{$item->class_css};width:70px; height:15px;;float:left");
         $objects[] = $helper->parseProperty("html", "#name" . $item->id, $item->name);
         $objects[] = $helper->parsePropertyPublish("html", "#publish" . $item->id, $item->published, $number);
         $objects[] = $helper->parsePropertyPublish("html", "#show_on_tab" . $item->id, $item->show_on_tab, $number, 'hidden', 'Show', 'Hidden');
         $objects[] = $helper->parseProperty("html", "#title" . $item->id, $item->title);
         //$objects [] = $helper->parsePropertyPublisha ( $item->id, $item->published );
     } else {
         $objects[] = $helper->parseProperty("html", "#system-message", $helper->message(1, $errors));
     }
     $helper = new JAVoiceHelpers();
     echo $helper->parse_JSON_new($objects);
     exit;
 }
Exemplo n.º 8
0
 function saveResponse()
 {
     global $javconfig;
     $model = $this->getModel('items');
     $post = JRequest::get('request', JREQUEST_ALLOWRAW);
     $post['content'] = $post['newVoiceContent'];
     $model->setState('request', $post);
     $row = $model->store_admin_response();
     $helper = new JAVoiceHelpers();
     $objects = array();
     $errors = array();
     $objects = array();
     $cid = JRequest::getVar('cid', array(0), '', 'array');
     JArrayHelper::toInteger($cid, array(0));
     if (!$cid) {
         $errors[] = JText::_("ERROR_OCCURRED_DATA_NOT_SAVED");
         $objects[] = $helper->parseProperty("html", "#system-message", $helper->message(1, $errors));
     } else {
         if ($row->id) {
             if ($javconfig['plugin']->get("is_attach_image", 0)) {
                 jimport('joomla.filesystem.folder');
                 jimport('joomla.filesystem.file');
                 //delete file in store image if remove file
                 $listFile = JRequest::getVar('listfile', 0);
                 $file_path = JPATH_ROOT . DS . "images" . DS . "stories" . DS . "ja_voice" . DS . "admin_response" . DS . $row->id;
                 $listFileOfComments = JFolder::files($file_path);
                 if ($listFileOfComments) {
                     foreach ($listFileOfComments as $listFileOfComment) {
                         if ($listFile) {
                             if (!in_array($listFileOfComment, $listFile)) {
                                 JFile::delete($file_path . DS . $listFileOfComment);
                             }
                         } else {
                             JFile::delete($file_path . DS . $listFileOfComment);
                         }
                     }
                 }
                 //die($_SESSION['javReplyTemp']."--");
                 if ($listFile) {
                     if (isset($_SESSION['javReplyTemp'])) {
                         $listFileTemp = JFolder::files($_SESSION['javReplyTemp']);
                         if ($listFileTemp) {
                             foreach ($listFileTemp as $file) {
                                 if (!in_array($file, $listFile, true)) {
                                     JFile::delete($_SESSION['javReplyTemp'] . DS . $file);
                                 }
                             }
                         }
                         JRequest::setVar("listfile", implode(',', $listFile));
                         //move file
                         $target_path = JPATH_ROOT . DS . "images" . DS . "stories" . DS . "ja_voice" . DS . "admin_response" . DS . $row->id;
                         if (!is_dir($target_path)) {
                             JFolder::create($target_path);
                         }
                         if ($listFileTemp) {
                             JFolder::copy($_SESSION['javReplyTemp'], $target_path, '', true);
                         }
                         JFolder::delete($_SESSION['javReplyTemp']);
                         unset($_SESSION['javtemp']);
                         unset($_SESSION['javReplyNameFolder']);
                     }
                 }
             }
             $message[] = JText::_("SAVE_DATA_SUCCESSFULLY");
             $objects[] = $helper->parseProperty("html", "#system-message", $helper->message(0, $message));
         } else {
             $errors[] = JText::_("ERROR_OCCURRED_DATA_NOT_SAVED");
             $objects[] = $helper->parseProperty("html", "#system-message", $helper->message(1, $errors));
         }
     }
     $helper = new JAVoiceHelpers();
     echo $helper->parse_JSON_new($objects);
     exit;
 }