Example #1
0
File: Tags.php Project: ph7pal/momo
 public static function findAndAdd($title, $classify, $logid)
 {
     $title = zmf::filterInput($title, 't', 1);
     if (!$title) {
         return false;
     }
     $info = Tags::model()->find('title=:title AND classify=:classify', array(':title' => $title, ':classify' => $classify));
     if (!$info) {
         if (Yii::app()->session['checkHasBadword'] == 'yes') {
             $status = Posts::STATUS_STAYCHECK;
         } else {
             $status = Posts::STATUS_PASSED;
         }
         unset(Yii::app()->session['checkHasBadword']);
         $_data = array('title' => $title, 'name' => zmf::pinyin($title), 'classify' => $classify, 'status' => $status, 'cTime' => time(), 'length' => mb_strlen($title, 'GBK'));
         $modelB = new Tags();
         $modelB->attributes = $_data;
         if ($modelB->save()) {
             $tagid = $modelB->id;
         }
     } else {
         $tagid = $info['id'];
     }
     if ($tagid && $logid) {
         $_info = TagRelation::model()->find('tagid=:tagid AND logid=:logid AND classify=:classify', array(':tagid' => $tagid, ':logid' => $logid, ':classify' => $classify));
         if (!$_info) {
             $_tagre = array('tagid' => $tagid, 'logid' => $logid, 'classify' => $classify, 'cTime' => zmf::now());
             $modelC = new TagRelation();
             $modelC->attributes = $_tagre;
             $modelC->save();
         }
     }
     return $tagid;
 }
Example #2
0
 private static function addTags($model)
 {
     // add tags
     if (!empty($_POST['tags'])) {
         $taglist = explode(',', $_POST['tags']);
         if ($taglist !== false) {
             foreach ($taglist as &$tag) {
                 if ($tag === '') {
                     continue;
                 }
                 if (substr($tag, 0, 1) != '#') {
                     $tag = '#' . $tag;
                 }
                 $tagModel = new Tags();
                 $tagModel->taggedBy = 'API';
                 $tagModel->timestamp = time();
                 $tagModel->type = get_class($model);
                 $tagModel->itemId = $model->id;
                 $tagModel->tag = $tag;
                 $tagModel->itemName = $model->name;
                 $tagModel->save();
                 X2Flow::trigger('RecordTagAddTrigger', array('model' => $model, 'tags' => $tag));
             }
         }
     }
 }
Example #3
0
 public function addAction()
 {
     if ($this->_status['response']['status'] && $this->_checkToken()) {
         $this->_status['response']['status'] = false;
         $this->_status['response']['code'] = 301;
     }
     $post = ['entry' => true];
     if ($this->_status['response']['status'] && !$this->_getPost($post)) {
         $this->_status['response']['status'] = false;
         $this->_status['response']['code'] = 201;
         $this->_status['response']['detail'] = $post['empty'];
     }
     $templateList = ['title' => null, 'tag' => null, 'category' => null, 'content' => null];
     $conditions = ['content'];
     if ($this->_status['response']['status'] && !$this->_mergeArray($this->_post['entry'], $templateList, $conditions)) {
         $this->_status['response']['status'] = false;
         $this->_status['response']['code'] = 202;
         $this->_status['response']['detail'] = $conditions;
     }
     if (!$this->_status['response']['status']) {
         return $this->response->setJsonContent($this->_status);
     }
     $posts = new Posts();
     $posts->assign(['author' => $this->_id, 'title' => $this->_post['entry']['title'], 'content' => $this->_post['entry']['content']]);
     if (!$posts->save()) {
         $this->_status['response']['status'] = false;
         $this->_status['response']['code'] = 102;
         return $this->response->setJsonContent($this->_status);
     }
     if (!empty($this->_post['entry']['tag'])) {
         if (is_string($this->_post['entry']['tag'])) {
             $this->_post['entry']['tag'] = (array) $this->_post['entry']['tag'];
         }
         foreach ($this->_post['entry']['tag'] as $tag) {
             $tags = new Tags();
             $tags->assign(['posts_id' => $posts->id, 'tag' => $tag]);
             if (!$tags->save()) {
                 $this->_status['response']['status'] = false;
                 $this->_status['response']['code'] = 102;
                 return $this->response->setJsonContent($this->_status);
             }
         }
     }
     if (!empty($this->_post['entry']['category'])) {
         if (is_string($this->_post['entry']['category'])) {
             $this->_post['entry']['category'] = (array) $this->_post['entry']['category'];
         }
         foreach ($this->_post['entry']['category'] as $category) {
             $categories = new Categories();
             $categories->assign(['posts_id' => $posts->id, 'category' => $category]);
             if (!$categories->save()) {
                 $this->_status['response']['status'] = false;
                 $this->_status['response']['code'] = 102;
                 return $this->response->setJsonContent($this->_status);
             }
         }
     }
     return $this->response->setJsonContent($this->_status);
 }
Example #4
0
 public function getTagByName($name)
 {
     $tag = Tags::findFirst(['conditions' => 'name = :name:', 'bind' => ['name' => $name]]);
     if (null == $tag) {
         $tag = new Tags();
         $tag->name = $name;
         $tag->save();
     }
     return $tag;
 }
Example #5
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Tags();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Tags'])) {
         $model->attributes = $_POST['Tags'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
Example #6
0
 public function afterSave($event)
 {
     $attribute = $this->attribute;
     if ($this->owner->{$attribute}) {
         $model = $this->getModel();
         if ($model) {
             $model->tags = $this->owner->{$attribute};
             $model->save();
         } else {
             $model = new Tags();
             $model->attributes = array('model' => $this->owner->tableName(), 'pk' => $this->owner->id, 'tags' => $this->owner->{$attribute});
             $model->save();
         }
     }
 }
Example #7
0
 /**
  * Creates a new tag
  */
 public function createAction()
 {
     if (!$this->request->isPost()) {
         return $this->dispatcher->forward(array("controller" => "tags", "action" => "index"));
     }
     $tag = new Tags();
     $tag->id = $this->request->getPost("id");
     $tag->tag = $this->request->getPost("tag");
     if (!$tag->save()) {
         foreach ($tag->getMessages() as $message) {
             $this->flash->error($message);
         }
         return $this->dispatcher->forward(array("controller" => "tags", "action" => "new"));
     }
     $this->flash->success("tag was created successfully");
     return $this->dispatcher->forward(array("controller" => "tags", "action" => "index"));
 }
 public function newAction()
 {
     $response = new ApiResponse();
     if ($this->request->isPost()) {
         $tag = new Tags();
         $tag->id = uniqid();
         $tag->name = $this->request->getPost('name');
         if ($this->request->hasFiles() == true) {
             $baseLocation = 'files/';
             foreach ($this->request->getUploadedFiles() as $file) {
                 $photos = new Photos();
                 $unique_filename = $tag->id;
                 $photos->size = $file->getSize();
                 $photos->original_name = $file->getName();
                 $photos->file_name = $unique_filename;
                 $photos->extension = $file->getExtension();
                 $location = $baseLocation . $unique_filename . "." . $file->getExtension();
                 $photos->public_link = $location;
                 try {
                     if (!$photos->save()) {
                         $response->setResponseError($photos->getMessages());
                     } else {
                         //Move the file into the application
                         $file->moveTo($location);
                         $tag->icon = $photos->public_link;
                     }
                 } catch (PDOException $e) {
                     $response->setResponseError($e->getMessage());
                 }
             }
         }
         try {
             if ($tag->save() == false) {
                 $response->setResponseError($tag->getMessages());
             } else {
                 $response->setResponseMessage($tag->id);
             }
         } catch (PDOException $e) {
             $response->setResponseError($e->getMessage());
         }
     } else {
         $response->setResponseError('Wrong HTTP Method');
     }
     return $response;
 }
Example #9
0
 public function actionCreate($id = '')
 {
     $this->checkPower('addTag');
     if ($id) {
         $model = Tags::model()->findByPk($id);
         if (!$model) {
             $this->message(0, '该标签不存在');
         }
     } else {
         $model = new Tags();
         $model->classify = 'posts';
     }
     if (isset($_POST['Tags'])) {
         $model->attributes = $_POST['Tags'];
         if ($model->save()) {
             $this->redirect(array('index'));
         }
     }
     $this->render('create', array('model' => $model));
 }
Example #10
0
 /**
  * Adds tags to a post
  */
 public function addTags($tags)
 {
     foreach ($tags as $t) {
         $t = trim($t);
         $tag = Tags::findFirst(array("tag = '{$t}'"));
         if (!$tag) {
             $tag = new Tags();
             $tag->tag = $t;
             $tag->save();
         }
         $postTag = PostTags::findFirst(array("conditions" => "posts_id = ?1 AND tags_id = ?2", "bind" => array(1 => $this->id, 2 => $tag->id)));
         if (!$postTag) {
             $postTag = new PostTags();
             $postTag->posts_id = $this->id;
             $postTag->tags_id = $tag->id;
             $postTag->save();
         }
         unset($tag);
         unset($postTag);
     }
 }
Example #11
0
 /**
  * 检查传入的标签是否已存在,不存在则创建,并检查是否已存在对应关系,不存在则创建
  * @param type $id
  * @param type $crumb
  */
 public function checkAndWriteTag($id, $crumb, $tagid = 0)
 {
     if (!$tagid) {
         $_crumb = strip_tags(trim($crumb));
         $_taginfo = Tags::model()->find('title=:title', array(':title' => $_crumb));
         if (!$_taginfo) {
             $_tagdata = array('title' => $_crumb, 'name' => zmf::pinyin($_crumb), 'classify' => 'posts', 'cTime' => time(), 'status' => 1);
             $model_tag = new Tags();
             $model_tag->attributes = $_tagdata;
             $_tagid = $model_tag->save(false);
         } else {
             $_tagid = $_taginfo['id'];
         }
     } else {
         $_tagid = $tagid;
     }
     $_tagrel = array('logid' => $id, 'tagid' => $_tagid, 'classify' => 'posts');
     $reinfo = TagRelation::model()->find('logid=:logid AND tagid=:tagid AND classify="posts"', array(':logid' => $id, ':tagid' => $_tagid));
     if (!$reinfo) {
         $model_tagrel = new TagRelation();
         $model_tagrel->attributes = $_tagrel;
         $model_tagrel->save(false);
     }
 }
Example #12
0
        template($tpl_file);
        exit;
    }
    if ($do == "search" && !empty($_GET['q'])) {
        $conditions[] = "Tag.name like '%" . trim($_GET['q']) . "%'";
    }
    if ($do == "del" && !empty($id)) {
        $tag->del($id);
    }
}
if (isset($_POST['del']) && !empty($_POST['id'])) {
    $tag->del($_POST['id']);
}
if (isset($_POST['save']) && !empty($_POST['data']['tag'])) {
    if (isset($_POST['id'])) {
        $id = intval($_POST['id']);
    }
    if ($id) {
        $tag->save($_POST['data']['tag'], "update", $id);
    } else {
        $tag->save($_POST['data']['tag']);
    }
}
$amount = $tag->findCount(null, $conditions);
$page = new Pages();
$page->setPagenav($amount);
//$joins[] = "LEFT JOIN {$tb_prefix}members m ON m.id=Tag.member_id";
$result = $tag->findAll("Tag.*", $joins, $conditions, "Tag.id DESC ", $page->firstcount, $page->displaypg);
setvar("Items", $result);
setvar("ByPages", $page->getPagenav());
template($tpl_file);
 public function actionSave_article()
 {
     $idArticle = null;
     // Проверки на доступ к странице
     if (Yii::app()->user->isGuest) {
         $this->redirect($this->createAbsoluteUrl('default/index'));
     }
     if (isset($_POST['cancel'])) {
         $this->redirect($this->createAbsoluteUrl('default/list_articles', $_GET));
     }
     if (isset($_POST['delete'])) {
         $this->actionDelete_article();
         $this->redirect($this->createAbsoluteUrl('default/list_articles', $_GET));
     }
     // Автокомплитер тегов
     if (isset($_GET['q'])) {
         $lastTag = end(explode(",", $_GET['q']));
         $criteria = new CDbCriteria();
         $criteria->condition = 'textTag LIKE :tag';
         $criteria->params = array(':tag' => '%' . trim(htmlspecialchars($lastTag)) . '%');
         if (isset($_GET['limit']) && is_numeric($_GET['limit'])) {
             $criteria->limit = $_GET['limit'];
         }
         $tags = Tags::model()->findAll($criteria);
         if ($tags) {
             $resStr = '';
             foreach ($tags as $tag) {
                 $resStr .= $tag->textTag . "\n";
             }
             echo $resStr;
         }
         exit;
     }
     // Редактирование или добавление новой
     if (isset($_GET['idArticle'])) {
         $idArticle = $_GET['idArticle'];
         $model = Articles::model()->findByPk($_GET['idArticle']);
         $model['tagArray'] = AuxiliaryFunctions::getTagsList($model->tagstoarticles, false);
     } else {
         $model = new Articles('create');
     }
     // Нажата кнопка "Редактировать" или "Добавить"
     if (isset($_POST['Articles'])) {
         $oldFile = null;
         $oldFile = $model->photo;
         $fileName = null;
         // Генерим имя фото
         if ('' != $_FILES['Articles']['name']['image']) {
             $fileName = AuxiliaryFunctions::getUniquNamePhoto($_FILES['Articles']['name']['image']);
             $_POST['Articles']['photo'] = $fileName;
             $oldFile = $model->photo;
         }
         $model->attributes = $_POST['Articles'];
         if (empty($model->idUser)) {
             $model->idUser = Users::getIdUserForAdmin();
         }
         if ($model->validate()) {
             if ($model->save()) {
                 $idArticle = $model->idArticle;
                 if ($fileName) {
                     AuxiliaryFunctions::savePhoto($model, $fileName, $oldFile);
                 }
                 // Теги для статьи
                 if (isset($_POST['textTag'])) {
                     $tagsArray = explode(",", $_POST['textTag']);
                     $idArray = array();
                     foreach ($tagsArray as $item) {
                         $tagId = null;
                         if (!empty($item)) {
                             $item = trim(htmlspecialchars($item));
                         } else {
                             continue;
                         }
                         $tagResult = Tags::model()->findByAttributes(array('textTag' => $item));
                         if (null === $tagResult) {
                             $newTag = new Tags();
                             $newTag->textTag = $item;
                             if ($newTag->save()) {
                                 $tagId = $newTag->idTag;
                             }
                         } else {
                             $tagId = $tagResult->idTag;
                         }
                         $idArray[] = $tagId;
                     }
                     if ($idArray) {
                         foreach ($idArray as $item) {
                             $item = (int) $item;
                             $idArticle = (int) $idArticle;
                             if (!TagsToArticles::model()->exists('idArticle = :idArticle AND idTag = :idTag', array(':idArticle' => $idArticle, ':idTag' => $item))) {
                                 $newTags2Art = new TagsToArticles();
                                 $newTags2Art->idArticle = $idArticle;
                                 $newTags2Art->idTag = (int) $item;
                                 $newTags2Art->save();
                             }
                         }
                     }
                 }
                 $this->redirect($this->createAbsoluteUrl('default/list_articles', $_GET));
             }
         }
     }
     $menus = Mainmenu::model()->getDropDownMenu();
     $idMenu = !empty($model->idMenu) ? $model->idMenu : key($menus);
     $category1 = array('' => 'Без категории');
     $category2 = Categorys::getAllCategories($idMenu);
     $category = $category1 + $category2;
     $tags = new Tags();
     $this->render('//articles/save_article', array('model' => $model, 'menus' => $menus, 'category' => $category, 'tags' => $tags));
 }
Example #14
0
  * This is done by:
  * 1) Getting/creating the tag
  * 2) Creating an imageTag
  * 3) Saving the imageTag
  */
 foreach ($data as $tagRow) {
     $name = $filter->sanitize($tagRow['name'], 'string');
     //Get tag if it exists already
     $tag = Tags::findFirst("name = '" . $name . "' AND category_id = '" . $tagRow['category_id'] . "'");
     if (!$tag) {
         $tag = new Tags();
     }
     $tag->name = $name;
     $tag->category_id = $tagRow['category_id'];
     //If the tag could not be saved, dump the error messages
     if (!$tag->save()) {
         echo 'could not save tag.';
         var_dump($tagRow);
         var_dump($tag->getMessages());
         $app->response->setStatusCode('500');
         $app->response->send();
     }
     $tag->refresh();
     //Create an imageTag for each tag
     $imagesTags = new ImagesTags();
     $imagesTags->tag_id = $tag->id;
     $imagesTags->image_id = $image->id;
     $imagesTags->x = $tagRow['x'];
     $imagesTags->y = $tagRow['y'];
     $imagesTags->user_id = $user->getFbId();
     //If the imageTag could not be saved, dump the error message
 /**
  * Save a product in the database (Create if need be)
  *
  * @param string $passkey
  * @param int $intRowid
  * @param string $strCode
  * @param string $strName
  * @param string $blbImage
  * @param string $strClassName
  * @param int $blnCurrent
  * @param string $strDescription
  * @param string $strDescriptionShort
  * @param string $strFamily
  * @param int $blnGiftCard
  * @param int $blnInventoried
  * @param double $fltInventory
  * @param double $fltInventoryTotal
  * @param int $blnMasterModel
  * @param int $intMasterId
  * @param string $strProductColor
  * @param string $strProductSize
  * @param double $fltProductHeight
  * @param double $fltProductLength
  * @param double $fltProductWidth
  * @param double $fltProductWeight
  * @param int $intTaxStatusId
  * @param double $fltSell
  * @param double $fltSellTaxInclusive
  * @param double $fltSellWeb
  * @param string $strUpc
  * @param int $blnOnWeb
  * @param string $strWebKeyword1
  * @param string $strWebKeyword2
  * @param string $strWebKeyword3
  * @param int $blnFeatured
  * @param string $strCategoryPath
  * @return string
  */
 public function save_product($passkey, $intRowid, $strCode, $strName, $blbImage, $strClassName, $blnCurrent, $strDescription, $strDescriptionShort, $strFamily, $blnGiftCard, $blnInventoried, $fltInventory, $fltInventoryTotal, $blnMasterModel, $intMasterId, $strProductColor, $strProductSize, $fltProductHeight, $fltProductLength, $fltProductWidth, $fltProductWeight, $intTaxStatusId, $fltSell, $fltSellTaxInclusive, $fltSellWeb, $strUpc, $blnOnWeb, $strWebKeyword1, $strWebKeyword2, $strWebKeyword3, $blnFeatured, $strCategoryPath)
 {
     if (!$this->check_passkey($passkey)) {
         return self::FAIL_AUTH;
     }
     // We must preservice the Rowid of Products within the Web Store
     // database and must therefore see if it already exists
     $objProduct = Product::model()->findByPk($intRowid);
     if (!$objProduct) {
         $objProduct = new Product();
         $objProduct->id = $intRowid;
     }
     $strName = trim($strName);
     $strName = trim($strName, '-');
     $strName = substr($strName, 0, 255);
     $strCode = trim($strCode);
     $strCode = str_replace('"', '', $strCode);
     $strCode = str_replace("'", '', $strCode);
     if (empty($strName)) {
         $strName = 'missing-name';
     }
     if (empty($strDescription)) {
         $strDescription = '';
     }
     $objProduct->code = $strCode;
     $objProduct->title = $strName;
     //$objProduct->class_name = $strClassName;
     $objProduct->current = $blnCurrent;
     $objProduct->description_long = $strDescription;
     $objProduct->description_short = $strDescriptionShort;
     //$objProduct->family = $strFamily;
     $objProduct->gift_card = $blnGiftCard;
     $objProduct->inventoried = $blnInventoried;
     $objProduct->inventory = $fltInventory;
     $objProduct->inventory_total = $fltInventoryTotal;
     $objProduct->master_model = $blnMasterModel;
     if ($intMasterId > 0) {
         $objProduct->parent = $intMasterId;
     } else {
         $objProduct->parent = null;
     }
     $objProduct->product_color = $strProductColor;
     $objProduct->product_size = $strProductSize;
     $objProduct->product_height = $fltProductHeight;
     $objProduct->product_length = $fltProductLength;
     $objProduct->product_width = $fltProductWidth;
     $objProduct->product_weight = $fltProductWeight;
     $objProduct->tax_status_id = $intTaxStatusId;
     $objProduct->sell = $fltSell;
     $objProduct->sell_tax_inclusive = $fltSellTaxInclusive;
     //If we're in TaxIn Mode, then SellWeb has tax and we reverse it.
     if (_xls_get_conf('TAX_INCLUSIVE_PRICING', 0) == 1) {
         if ($fltSellWeb != 0) {
             //Tax in with a sell on web price
             $objProduct->sell_web_tax_inclusive = $fltSellWeb;
             //LS sends tax in web already
             $objProduct->sell_web = Tax::StripTaxesFromPrice($fltSellWeb, $intTaxStatusId);
         } else {
             //We use our regular prices and copy them price
             $objProduct->sell_web_tax_inclusive = $fltSellTaxInclusive;
             $objProduct->sell_web = $fltSell;
         }
     } else {
         if ($fltSellWeb != 0) {
             $objProduct->sell_web = $fltSellWeb;
         } else {
             $objProduct->sell_web = $fltSell;
         }
     }
     $objProduct->upc = $strUpc;
     $objProduct->web = $blnOnWeb;
     $objProduct->featured = $blnFeatured;
     $fltReserved = $objProduct->CalculateReservedInventory();
     $objProduct->inventory_reserved = $fltReserved;
     if (Yii::app()->params['INVENTORY_FIELD_TOTAL'] == 1) {
         $objProduct->inventory_avail = $fltInventoryTotal - $fltReserved;
     } else {
         $objProduct->inventory_avail = $fltInventory - $fltReserved;
     }
     //Because Lightspeed may send us products out of sequence (child before parent), we have to turn this off
     Yii::app()->db->createCommand('SET FOREIGN_KEY_CHECKS=0;')->execute();
     if (!$objProduct->save()) {
         Yii::log("SOAP ERROR : Error saving product {$intRowid} {$strCode} " . print_r($objProduct->getErrors(), true), 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
         return self::UNKNOWN_ERROR . " Error saving product {$intRowid} {$strCode} " . print_r($objProduct->getErrors(), true);
     }
     $strFeatured = _xls_get_conf('FEATURED_KEYWORD', 'XnotsetX');
     if (empty($strFeatured)) {
         $strFeatured = 'XnotsetX';
     }
     //Save keywords
     $strTags = trim($strWebKeyword1) . "," . trim($strWebKeyword2) . "," . trim($strWebKeyword3);
     $strTags = str_replace(",,", ",", $strTags);
     $arrTags = explode(",", $strTags);
     ProductTags::DeleteProductTags($objProduct->id);
     foreach ($arrTags as $indivTag) {
         if (!empty($indivTag)) {
             $tag = Tags::model()->findByAttributes(array('tag' => $indivTag));
             if (!$tag instanceof Tags) {
                 $tag = new Tags();
                 $tag->tag = $indivTag;
                 $tag->save();
             }
             $objProductTag = new ProductTags();
             $objProductTag->product_id = $objProduct->id;
             $objProductTag->tag_id = $tag->id;
             $objProductTag->save();
             if ($strFeatured != 'XnotsetX' && $objProduct->web && $indivTag == $strFeatured) {
                 $objProduct->featured = 1;
                 $objProduct->save();
             }
         }
     }
     if (!empty($strFamily)) {
         $objFamily = Family::model()->findByAttributes(array('family' => $strFamily));
         if ($objFamily instanceof Family) {
             $objProduct->family_id = $objFamily->id;
             $objProduct->save();
         } else {
             $objFamily = new Family();
             $objFamily->family = $strFamily;
             $objFamily->child_count = 0;
             $objFamily->request_url = _xls_seo_url($strFamily);
             $objFamily->save();
             $objProduct->family_id = $objFamily->id;
             $objProduct->save();
         }
         $objFamily->UpdateChildCount();
     } else {
         if ($objProduct->family_id) {
             $objFamily = Family::model()->findByAttributes(array('id' => $objProduct->family_id));
             $objProduct->family_id = null;
             $objProduct->save();
             $objFamily->UpdateChildCount();
         }
     }
     if (!empty($strClassName)) {
         $objClass = Classes::model()->findByAttributes(array('class_name' => $strClassName));
         if ($objClass instanceof Classes) {
             $objProduct->class_id = $objClass->id;
             $objProduct->save();
         } else {
             $objClass = new Classes();
             $objClass->class_name = $strClassName;
             $objClass->child_count = 0;
             $objClass->request_url = _xls_seo_url($strClassName);
             $objClass->save();
             $objProduct->class_id = $objClass->id;
             $objProduct->save();
         }
         $objClass->UpdateChildCount();
     }
     // Save category
     $strCategoryPath = trim($strCategoryPath);
     if ($strCategoryPath && $strCategoryPath != "Default") {
         $arrCategories = explode("\t", $strCategoryPath);
         $intCategory = Category::GetIdByTrail($arrCategories);
         if (!is_null($intCategory)) {
             $objCategory = Category::model()->findByPk($intCategory);
             //Delete any prior categories from the table
             ProductCategoryAssn::model()->deleteAllByAttributes(array('product_id' => $objProduct->id));
             $objAssn = new ProductCategoryAssn();
             $objAssn->product_id = $objProduct->id;
             $objAssn->category_id = $intCategory;
             $objAssn->save();
             $objCategory->UpdateChildCount();
         }
     } else {
         ProductCategoryAssn::model()->deleteAllByAttributes(array('product_id' => $objProduct->id));
     }
     Product::convertSEO($intRowid);
     //Build request_url
     Yii::app()->db->createCommand('SET FOREIGN_KEY_CHECKS=1;')->execute();
     $objEvent = new CEventProduct('LegacysoapController', 'onSaveProduct', $objProduct);
     _xls_raise_events('CEventProduct', $objEvent);
     //
     return self::OK;
 }
Example #16
0
 public function actionUpdateTags()
 {
     $selectedtags = $_REQUEST['selectedtags'];
     $userid = $_REQUEST['userid'];
     $selectedtags = explode(",", $selectedtags);
     //echo $selectedtags."-".$userid;
     //exit;
     $command = Yii::app()->db->createCommand();
     $checkprevtags = Tags::model()->findAllByAttributes(array('user_id' => $userid));
     if (isset($checkprevtags)) {
         $command->delete('pv_tags', 'user_id = :user_id ', array(':user_id' => $userid));
     }
     foreach ($selectedtags as $eachtag) {
         $newtag = new Tags();
         $newtag->tag_id = $eachtag;
         $newtag->user_id = $userid;
         $newtag->status = 1;
         $newtag->created_date = new CDbExpression('NOW()');
         if ($newtag->save(FALSE)) {
             $saved = true;
         }
     }
     if ($saved) {
         echo "saved";
     } else {
         echo "error";
     }
 }
Example #17
0
 public function actionEdit()
 {
     $this->layout = '//layouts/admin';
     $success = false;
     $id = $_REQUEST['id'];
     $model = NewsCategories::model()->findByPk($id);
     $this->pageTitle = is_object($model) ? $model->name : 'Новая категория';
     $this->breadcrumbs = array('Новости' => array('/admin/news'), 'Категории' => array('/admin/news/categories/list'), is_object($model) ? $model->name : 'Новая категория');
     if (isset($_POST['data']) && is_object($model)) {
         $tags = array();
         if (isset($_POST['data']['tags'])) {
             $tags = $_POST['data']['tags'];
             unset($_POST['data']['tags']);
         }
         $dataArray = $_POST['data'];
         $dataArray['is_active'] = isset($_POST['data']['is_active']) && $_POST['data']['is_active'] == 1 ? 1 : 0;
         $model->setAttributes($dataArray);
         if ($model->save()) {
             $success = true;
             if (isset($_FILES['anons_pic']) && $_FILES['anons_pic']['name'] || isset($_FILES['content_pic']) && $_FILES['content_pic']['name']) {
                 $uploaddir = 'images/upload/' . date("d.m.Y", time());
                 if (!is_dir($uploaddir)) {
                     mkdir($uploaddir);
                 }
                 if (isset($_FILES['anons_pic']) && $_FILES["anons_pic"]["name"]) {
                     if ($model->anons_pic) {
                         $anons_pic = Yii::app()->basePath . "/.." . $model->anons_pic;
                         if (is_file($anons_pic)) {
                             unlink($anons_pic);
                         }
                     }
                     $tmp_name = $_FILES["anons_pic"]["tmp_name"];
                     $name = $_FILES["anons_pic"]["name"];
                     if ($name) {
                         $uploadfile = $uploaddir . 'arca_' . $model->id . '_' . md5(basename($name) . time()) . "." . end(explode(".", $name));
                         if (move_uploaded_file($tmp_name, $uploadfile)) {
                             $model->setAttributes(array("anons_pic" => "/" . $uploadfile));
                             if (!$model->save()) {
                                 print_r($model->errors);
                                 die;
                             }
                         }
                     }
                 }
                 if (isset($_FILES['content_pic']) && $_FILES["content_pic"]["name"]) {
                     if ($model->content_pic) {
                         $content_pic = Yii::app()->basePath . "/.." . $model->content_pic;
                         if (is_file($content_pic)) {
                             unlink($content_pic);
                         }
                     }
                     $tmp_name = $_FILES["content_pic"]["tmp_name"];
                     $name = $_FILES["content_pic"]["name"];
                     if ($name) {
                         $uploadfile = $uploaddir . 'arcc_' . $model->id . '_' . md5(basename($name) . time()) . "." . end(explode(".", $name));
                         if (move_uploaded_file($tmp_name, $uploadfile)) {
                             $model->setAttributes(array("content_pic" => "/" . $uploadfile));
                             $model->save();
                         }
                     }
                 }
             }
             if (is_array($tags) && count($tags)) {
                 $trs = TagsRelations::model()->findAllByAttributes(array("object_id" => $id, "model" => "news_category"));
                 if (is_array($trs) && count($trs)) {
                     foreach ($trs as $tr) {
                         $tr->delete();
                     }
                 }
                 foreach ($tags as $tag) {
                     $tagModel = Tags::model()->findByAttributes(array("name" => $tag));
                     if (!is_object($tagModel)) {
                         $tagModel = new Tags();
                         $tagModel->setAttributes(array("name" => $tag, "count" => 0));
                     }
                     $tagModel->count += 1;
                     $tagModel->save();
                     $tagsRelations = new TagsRelations();
                     $tagsRelations->setAttributes(array("tag_id" => $tagModel->id, "object_id" => $model->id, "model" => "news_category"));
                     $tagsRelations->save();
                 }
             }
         }
     }
     $this->render('edit', array('model' => $model, 'success' => $success, 'errors' => $model->errors));
 }
Example #18
0
 /**
  * Adds the specified tag(s) to the owner model, but not
  * if the tag has already been added.
  * @param mixed $tags a string or array of strings containing tags
  * @return boolean whether or not at least one tag was added successfully
  */
 public function addTags($tags)
 {
     $result = false;
     $addedTags = array();
     foreach ((array) $tags as $tagName) {
         if (empty($tagName)) {
             continue;
         }
         if (!$this->hasTag($tagName)) {
             // check for duplicate tag
             $tag = new Tags();
             $tag->tag = Tags::normalizeTag($tagName);
             $tag->itemId = $this->getOwner()->id;
             $tag->type = get_class($this->getOwner());
             $tag->taggedBy = Yii::app()->getSuName();
             $tag->timestamp = time();
             $tag->itemName = $this->getOwner()->name;
             if ($tag->save()) {
                 $this->_tags[] = $tag->tag;
                 // update tag cache
                 $addedTags[] = $tagName;
                 $result = true;
             } else {
                 throw new CHttpException(422, 'Failed saving tag due to errors: ' . json_encode($tag->errors));
             }
         }
     }
     if ($this->flowTriggersEnabled) {
         X2Flow::trigger('RecordTagAddTrigger', array('model' => $this->getOwner(), 'tags' => $addedTags));
     }
     return $result;
 }
 public function actionVideoUpdate($id)
 {
     $this->pageTitle = 'Edit Video';
     if (!is_numeric($id)) {
         exit;
     }
     $VideoUpdate = false;
     $ModelVideo = CmsvideoVideo::model()->findByPk($id);
     $ModelTags = new Tags();
     if (isset($_POST['CmsvideoVideo'])) {
         $ModelVideo->attributes = $_POST['CmsvideoVideo'];
         $ImageUpload = CUploadedFile::getInstance($ModelVideo, 'video_image');
         if ($ImageUpload !== NULL || !empty($ModelVideo->video_imageurl)) {
             $ModelVideo->DeleteVideoImage($id);
             $ImageNewName = date("d-m-Y-H-i-s", time()) . "-" . $ModelVideo->video_alias . '.jpg';
             $ModelVideo->video_image = 'images/orginal/' . $ImageNewName;
             $ModelVideo->video_thumb = 'images/thumbs/' . $ImageNewName;
         }
         if ($ModelVideo->validate()) {
             if ($ImageUpload !== NULL) {
                 $ModelVideo->ImageCreate($ImageUpload, $ModelVideo->video_image);
             } elseif (!empty($ModelVideo->video_imageurl)) {
                 $ModelVideo->ImageCopy($ModelVideo->video_imageurl, $ModelVideo->video_image);
             }
             $ModelVideo->ImageThumbCreate($ModelVideo->video_image, $ModelVideo->video_thumb);
             if (!empty($ModelVideo->tag_slug)) {
                 $Tags = explode(',', $ModelVideo->tag_slug);
                 foreach ($Tags as $TagValue) {
                     $TagName = $ModelTags->ReplaceTagName($TagValue);
                     if (!empty($TagName)) {
                         if (Tags::model()->exists('tag_slug = :TagName', array(":TagName" => $TagName))) {
                         } else {
                             $ModelTags = new Tags();
                             $ModelTags->tag_slug = $TagName;
                             $ModelTags->tag_name = $TagValue;
                             $ModelTags->save();
                         }
                         $SelectTag = $ModelTags::model()->findByAttributes(array('tag_slug' => $TagName));
                         if (empty($SelectTag->tag_idvideo)) {
                             $TagIdVideo = array();
                             array_push($TagIdVideo, $id);
                             $NewTagIdVideo = serialize($TagIdVideo);
                             $ModelTags::model()->updateByPk($SelectTag->tag_id, array('tag_idvideo' => $NewTagIdVideo));
                         } else {
                             $TagIdVideo = unserialize($SelectTag->tag_idvideo);
                             if (is_array($TagIdVideo)) {
                                 if (!in_array($id, $TagIdVideo)) {
                                     array_push($TagIdVideo, $id);
                                     $NewTagIdVideo = serialize($TagIdVideo);
                                     $ModelTags::model()->updateByPk($SelectTag->tag_id, array('tag_idvideo' => $NewTagIdVideo));
                                 }
                             }
                         }
                         if (empty($ModelVideo->video_tags)) {
                             $TagsVideo = array();
                             array_push($TagsVideo, $SelectTag->tag_id);
                             $NewTagsVideo = serialize($TagsVideo);
                             $ModelVideo->video_tags = $NewTagsVideo;
                         } else {
                             $TagsVideo = unserialize($ModelVideo->video_tags);
                             if (is_array($TagsVideo)) {
                                 if (!in_array($SelectTag->tag_id, $TagsVideo)) {
                                     array_push($TagsVideo, $SelectTag->tag_id);
                                     $NewTagsVideo = serialize($TagsVideo);
                                     $ModelVideo->video_tags = $NewTagsVideo;
                                 }
                             }
                         }
                     }
                 }
             }
             $ModelVideo->save();
             if ($ModelVideo->tag_delete) {
                 $TagDelete = explode(',', $ModelVideo->tag_delete);
                 foreach ($TagDelete as $TagValue) {
                     $TagName = $ModelTags->ReplaceTagName($TagValue);
                     $SelectTag = $ModelTags::model()->findByAttributes(array('tag_slug' => $TagName));
                     if (Tags::model()->exists('tag_slug = :TagName', array(":TagName" => $TagName))) {
                         $TagArr1 = unserialize($SelectTag->tag_idvideo);
                         if (count(array_keys($TagArr1)) <= 1) {
                             $ModelTags::model()->deleteByPk($SelectTag->tag_id);
                         } else {
                             $TagArr2[] = $id;
                             $TagDelDiff = array_diff($TagArr1, $TagArr2);
                             $NewTag = serialize($TagDelDiff);
                             $ModelTags::model()->updateByPk($SelectTag->tag_id, array('tag_idvideo' => $NewTag));
                         }
                     }
                     if ($ModelVideo::model()->exists('video_id = :IdVideo AND video_tags LIKE :TagName', array(":TagName" => '%"' . $SelectTag->tag_id . '"%', ":IdVideo" => $id))) {
                         $SelectVideo = CmsvideoVideo::model()->findByPk($id);
                         $VideoTagArr1[] = $SelectTag->tag_id;
                         $VideoTagArr2 = unserialize($SelectVideo->video_tags);
                         $VideoDelDiff = array_diff($VideoTagArr2, $VideoTagArr1);
                         $NewTagVideo = serialize($VideoDelDiff);
                         $ModelVideo::model()->updateByPk($id, array('video_tags' => $NewTagVideo));
                     }
                 }
             }
             if ($ModelVideo->video_slider) {
                 $ImageNewName = date("d-m-Y-H-i-s", time()) . "-slider-" . $id . '.jpg';
                 $ImageUrl = 'images/orginal/' . $ImageNewName;
                 $ThumbUrl = 'images/thumbs/' . $ImageNewName;
                 $Slider = new Slider();
                 $Slider->ImageCopy($ModelVideo->video_image, $ImageUrl);
                 $Slider->ImageThumbCreate($ImageUrl, $ThumbUrl);
                 $Slider->slider_idvideo = $id;
                 $Slider->slider_title = $ModelVideo->video_title;
                 $Slider->slider_text = $ModelVideo->video_description;
                 $Slider->slider_image = $ImageUrl;
                 $Slider->slider_thumb = $ThumbUrl;
                 $Slider->slider_published = '1';
                 $Slider->save();
             }
             $VideoUpdate = true;
         }
         //   $this->redirect(array('admin/videos/'));
         //$this->redirect(Yii::app()->request->urlReferrer);
     }
     $this->render('videoupdate', array('ModelTags' => $ModelTags, 'ModelVideo' => $ModelVideo, 'VideoUpdate' => $VideoUpdate));
 }
Example #20
0
 /**
  * Sets the lastUpdated and updatedBy fields to reflect recent changes.
  * @param type $model The model to be updated
  * @return type $model The model with modified attributes
  */
 protected function updateChangelog($model, $change)
 {
     $model->lastUpdated = time();
     $model->updatedBy = Yii::app()->user->getName();
     $model->save();
     $type = get_class($model);
     if (substr($type, -1) != "s") {
         $type = substr($type, 0, -5) . "s";
     }
     $changelog = new Changelog();
     $changelog->type = $type;
     if (!isset($model->id)) {
         if ($model->save()) {
         }
     }
     $changelog->itemId = $model->id;
     $changelog->changedBy = Yii::app()->user->getName();
     $changelog->changed = $change;
     $changelog->timestamp = time();
     if ($changelog->save()) {
     }
     $changes = array();
     if ($change != 'Create' && $change != 'Completed' && $change != 'Edited') {
         if ($change != "") {
             $pieces = explode("<br />", $change);
             foreach ($pieces as $piece) {
                 $newPieces = explode("TO:", $piece);
                 $forDeletion = $newPieces[0];
                 if (isset($newPieces[1]) && preg_match('/<b>' . Yii::t('actions', 'color') . '<\\/b>/', $piece) == false) {
                     $changes[] = $newPieces[1];
                 }
                 preg_match_all('/(^|\\s|)#(\\w\\w+)/', $forDeletion, $deleteMatches);
                 $deleteMatches = $deleteMatches[0];
                 foreach ($deleteMatches as $match) {
                     $oldTag = Tags::model()->findByAttributes(array('tag' => substr($match, 1), 'type' => $type, 'itemId' => $model->id));
                     if (isset($oldTag)) {
                         $oldTag->delete();
                     }
                 }
             }
         }
     } else {
         if ($change == 'Create' || $change == 'Edited') {
             if ($model instanceof Contacts) {
                 $change = $model->backgroundInfo;
             } else {
                 if ($model instanceof Actions) {
                     $change = $model->actionDescription;
                 } else {
                     if ($model instanceof Docs) {
                         $change = $model->text;
                     } else {
                         $change = $model->name;
                     }
                 }
             }
         }
     }
     foreach ($changes as $change) {
         preg_match_all('/(^|\\s|)#(\\w\\w+)/', $change, $matches);
         $matches = $matches[0];
         foreach ($matches as $match) {
             $tag = new Tags();
             $tag->type = $type;
             $tag->taggedBy = Yii::app()->user->getName();
             $tag->type = $type;
             //cut out leading whitespace
             $tag->tag = trim($match);
             if ($model instanceof Contacts) {
                 $tag->itemName = $model->firstName . " " . $model->lastName;
             } else {
                 if ($model instanceof Actions) {
                     $tag->itemName = $model->actionDescription;
                 } else {
                     if ($model instanceof Docs) {
                         $tag->itemName = $model->title;
                     } else {
                         $tag->itemName = $model->name;
                     }
                 }
             }
             if (!isset($model->id)) {
                 $model->save();
             }
             $tag->itemId = $model->id;
             $tag->timestamp = time();
             //save tags including # sign
             if ($tag->save()) {
             }
         }
     }
     return $model;
 }
Example #21
0
 public function createtags()
 {
     try {
         $tags = new Tags($this->db, $this->entryid);
         $tags->update($this->tags);
         $tags->save(false);
         return true;
     } catch (Exception $e) {
         throw new ImageException('application error while setting tags', true);
     }
 }
Example #22
0
 public function actionEdit()
 {
     $this->layout = '//layouts/admin';
     $success = false;
     $id = $_REQUEST['id'];
     $model = CatalogObjects::model()->findByPk($id);
     $this->pageTitle = is_object($model) ? $model->name : 'Новый товар';
     $this->breadcrumbs = array('Каталог' => array('/admin/catalog'), is_object($model) ? $model->name : 'Новый товар');
     if (isset($_POST['data']) && is_object($model)) {
         $tags = array();
         if (isset($_POST['data']['tags'])) {
             $tags = $_POST['data']['tags'];
             unset($_POST['data']['tags']);
         }
         $dataArray = $_POST['data'];
         $additionalDataArray = isset($dataArray['additional']) ? $dataArray['additional'] : array();
         unset($dataArray['additional']);
         $dataArray['is_active'] = isset($_POST['data']['is_active']) && $_POST['data']['is_active'] == 1 ? 1 : 0;
         $dataArray['on_main'] = isset($_POST['data']['on_main']) && $_POST['data']['on_main'] == 1 ? 1 : 0;
         $model->setAttributes($dataArray);
         if ($model->save()) {
             $success = true;
             if (isset($_FILES['anons_pic']) || isset($_FILES['content_pic'])) {
                 $uploaddir = 'images/upload/' . date("d.m.Y", time());
                 if (!is_dir($uploaddir)) {
                     mkdir($uploaddir);
                 }
                 if (isset($_FILES['anons_pic']) && $_FILES["anons_pic"]["name"]) {
                     if ($model->anons_pic) {
                         $anons_pic = Yii::app()->basePath . "/.." . $model->anons_pic;
                         if (is_file($anons_pic)) {
                             unlink($anons_pic);
                         }
                     }
                     $tmp_name = $_FILES["anons_pic"]["tmp_name"];
                     $name = $_FILES["anons_pic"]["name"];
                     if ($name) {
                         $ext = explode(".", $name);
                         $uploadfile = $uploaddir . '/na_' . $model->id . '_' . md5(basename($name) . time()) . "." . end($ext);
                         if (move_uploaded_file($tmp_name, $uploadfile)) {
                             $model->setAttributes(array("anons_pic" => "/" . $uploadfile));
                             $model->save();
                         }
                     }
                 }
                 if (isset($_FILES['content_pic']) && $_FILES["content_pic"]["name"]) {
                     if ($model->content_pic) {
                         $content_pic = Yii::app()->basePath . "/.." . $model->content_pic;
                         if (is_file($content_pic)) {
                             unlink($content_pic);
                         }
                     }
                     $tmp_name = $_FILES["content_pic"]["tmp_name"];
                     $name = $_FILES["content_pic"]["name"];
                     if ($name) {
                         $ext = explode(".", $name);
                         $uploadfile = $uploaddir . '/nc_' . $model->id . '_' . md5(basename($name) . time()) . "." . end($ext);
                         if (move_uploaded_file($tmp_name, $uploadfile)) {
                             $model->setAttributes(array("content_pic" => "/" . $uploadfile));
                             $model->save();
                         }
                     }
                 }
                 if (isset($_FILES['extra_img']) && $_FILES["extra_img"]["name"]) {
                     if ($model->extra_img) {
                         $extra_img = Yii::app()->basePath . "/.." . $model->extra_img;
                         if (is_file($extra_img)) {
                             unlink($extra_img);
                         }
                     }
                     $tmp_name = $_FILES["extra_img"]["tmp_name"];
                     $name = $_FILES["extra_img"]["name"];
                     if ($name) {
                         $ext = explode(".", $name);
                         $uploadfile = $uploaddir . '/nc_' . $model->id . '_' . md5(basename($name) . time()) . "." . end($ext);
                         if (move_uploaded_file($tmp_name, $uploadfile)) {
                             $model->setAttributes(array("extra_img" => "/" . $uploadfile));
                             $model->save();
                         }
                     }
                 }
             }
             if (is_array($tags) && count($tags)) {
                 $trs = TagsRelations::model()->findAllByAttributes(array("object_id" => $id, "model" => "catalog_object"));
                 if (is_array($trs) && count($trs)) {
                     foreach ($trs as $tr) {
                         $tr->delete();
                     }
                 }
                 foreach ($tags as $tag) {
                     $tagModel = Tags::model()->findByAttributes(array("name" => $tag));
                     if (!is_object($tagModel)) {
                         $tagModel = new Tags();
                         $tagModel->setAttributes(array("name" => $tag, "count" => 0));
                     }
                     $tagModel->count += 1;
                     $tagModel->save();
                     $tagsRelations = new TagsRelations();
                     $tagsRelations->setAttributes(array("tag_id" => $tagModel->id, "object_id" => $model->id, "model" => "catalog_object"));
                     $tagsRelations->save();
                 }
             }
             if (is_array($additionalDataArray) && count($additionalDataArray)) {
                 foreach ($additionalDataArray as $fieldName => $data) {
                     $fieldModel = CatalogFilteredFields::model()->findByAttributes(array("name" => $fieldName, "category_id" => $model->category_id));
                     if (is_object($fieldModel)) {
                         switch ($fieldModel->data_type) {
                             case 'varchar':
                             case 'text':
                             case 'html':
                                 if ($data) {
                                     $newVal = FieldsValues::model()->findByAttributes(array("field_id" => $fieldModel->id, "object_id" => $model->id));
                                     if (!is_object($newVal)) {
                                         $newVal = new FieldsValues();
                                     }
                                     $newVal->setAttributes(array("field_id" => $fieldModel->id, "object_id" => $model->id, "text_val" => $data));
                                     $newVal->save();
                                 }
                                 break;
                             case 'int':
                             case 'list':
                                 if (is_numeric($data)) {
                                     $newVal = FieldsValues::model()->findByAttributes(array("field_id" => $fieldModel->id, "object_id" => $model->id));
                                     if (!is_object($newVal)) {
                                         $newVal = new FieldsValues();
                                     }
                                     $newVal->setAttributes(array("field_id" => $fieldModel->id, "object_id" => $model->id, "int_val" => $data));
                                     $newVal->save();
                                 }
                                 break;
                             case 'bool':
                                 $data = $data ? 1 : 0;
                                 $newVal = FieldsValues::model()->findByAttributes(array("field_id" => $fieldModel->id, "object_id" => $model->id));
                                 if (!is_object($newVal)) {
                                     $newVal = new FieldsValues();
                                 }
                                 $newVal->setAttributes(array("field_id" => $fieldModel->id, "object_id" => $model->id, "int_val" => $data));
                                 $newVal->save();
                                 break;
                             case 'date':
                                 $newVal = FieldsValues::model()->findByAttributes(array("field_id" => $fieldModel->id, "object_id" => $model->id));
                                 if (!is_object($newVal)) {
                                     $newVal = new FieldsValues();
                                 }
                                 $newVal->setAttributes(array("field_id" => $fieldModel->id, "object_id" => $model->id, "int_val" => strtotime($data)));
                                 $newVal->save();
                                 break;
                             case 'multiple':
                                 /* 09.04.2015
                                  * TODO: придумать что то лучше, чем удаление записей перед созданием новых...
                                  */
                                 if (is_array($data) && count($data) && $data[0]) {
                                     $oldValues = FieldsValues::model()->findAllByAttributes(array("field_id" => $fieldModel->id, "object_id" => $model->id));
                                     if (is_array($oldValues) && count($oldValues)) {
                                         foreach ($oldValues as $ov) {
                                             $ov->delete();
                                         }
                                     }
                                     if (is_array($data) && count($data)) {
                                         foreach ($data as $v) {
                                             $newVal = new FieldsValues();
                                             $newVal->setAttributes(array("field_id" => $fieldModel->id, "object_id" => $model->id, "int_val" => $v));
                                             $newVal->save();
                                         }
                                     }
                                 }
                                 break;
                         }
                     }
                 }
             }
         }
     }
     $this->render('edit', array('model' => $model, 'success' => $success, 'errors' => $model->errors));
 }