Esempio n. 1
0
 public function actionUpdateAjax()
 {
     if (demo()) {
         echo 'ok';
         Yii::app()->end();
     }
     $id = Yii::app()->request->getPost('id');
     $val = Yii::app()->request->getPost('val', '');
     if (!$id) {
         Yii::app()->user->setFlash('error', tt('Enter the required value'));
         echo 'error_save';
         Yii::app()->end();
     }
     $model = SocialpostingModel::model()->findByPk($id);
     /*if(!$val && !in_array($model->name, SocialpostingModel::model()->allowEmpty)) {
     			Yii::app()->user->setFlash('error', tt('Enter the required value'));
     			echo 'error_save';
     			Yii::app()->end();
     		}*/
     $model->value = $val;
     if ($model->save()) {
         echo 'ok';
     } else {
         Yii::app()->user->setFlash('error', tt('Enter the required value'));
         echo 'error_save';
     }
 }
Esempio n. 2
0
 public static function preparePosting(Apartment $model)
 {
     if ($model) {
         $message = '';
         $defaultLang = Lang::getDefaultLang();
         $tmp = 'title_' . $defaultLang;
         if (isset($model->{$tmp})) {
             $message .= $model->{$tmp};
         }
         // vkontakte
         if (SocialpostingModel::getSocialParamValue('useVkontakte')) {
             $vkApId = SocialpostingModel::getSocialParamValue('vkontakteApplicationId');
             $vkToken = SocialpostingModel::getSocialParamValue('vkontakteToken');
             $vkUsId = SocialpostingModel::getSocialParamValue('vkontakteUserId');
             //if ($vkApId && $vkToken && !is_numeric($model->autoVKPostId)) {
             if ($vkApId && $vkToken && utf8_strlen($model->autoVKPostId) < 1) {
                 if ($message) {
                     $imageUrl = null;
                     $res = Images::getMainThumb(300, 200, $model->images);
                     if ($res['link']) {
                         $imageUrl = $res['link'];
                     }
                     $post = self::addPostToVK($message, $vkApId, $vkToken, $vkUsId, $model->getUrl(), $imageUrl);
                     //logs(var_export($post, false));
                     //logs(var_export($post, true));
                     $postId = '0';
                     if ($post && isset($post->response)) {
                         $postId = isset($post->response->post_id) && $post->response->post_id ? $post->response->post_id : 0;
                     }
                     $model->autoVKPostId = $postId;
                     $model->update(array('autoVKPostId'));
                     /*$sql = 'UPDATE {{apartment}} SET autoVKPostId = "'.strip_tags(addslashes($postId)).'" WHERE id = '.$model->id;
                     		Yii::app()->db->createCommand($sql)->execute();*/
                 }
             }
         }
         // twitter
         if (SocialpostingModel::getSocialParamValue('useTwitter')) {
             $twApiKey = SocialpostingModel::getSocialParamValue('twitterApiKey');
             $twApiSecret = SocialpostingModel::getSocialParamValue('twitterApiSecret');
             $twTokenKey = SocialpostingModel::getSocialParamValue('twitterTokenKey');
             $twTokenSecret = SocialpostingModel::getSocialParamValue('twitterTokenSecret');
             //if ($twApiKey && $twApiSecret && $twTokenKey && $twTokenSecret && !is_numeric($model->autoTwitterPostId)) {
             if ($twApiKey && $twApiSecret && $twTokenKey && $twTokenSecret && utf8_strlen($model->autoTwitterPostId) < 1) {
                 if ($message) {
                     $post = self::addPostToTw($message, $twApiKey, $twApiSecret, $twTokenKey, $twTokenSecret, $model->getUrl());
                     //logs(var_export($post, false));
                     //logs(var_export($post, true));
                     $postId = '0';
                     if ($post && isset($post->id_str)) {
                         $postId = $post->id_str ? $post->id_str : 0;
                     }
                     $model->autoTwitterPostId = strip_tags(addslashes($postId));
                     $model->update(array('autoTwitterPostId'));
                     /*$sql = 'UPDATE {{apartment}} SET autoTwitterPostId = "'.strip_tags(addslashes($postId)).'" WHERE id = '.$model->id;
                     		Yii::app()->db->createCommand($sql)->execute();*/
                 }
             }
         }
     }
     return true;
 }
Esempio n. 3
0
<?php

$this->pageTitle = Yii::app()->name . ' - ' . tt('Configure the services of automatic posting');
$this->breadcrumbs = array(tt('Configure the services of automatic posting'));
$this->menu = array(array());
$this->adminTitle = tt('Configure the services of automatic posting');
$info = $infoHelp = '';
//if (!SocialpostingModel::getSocialParamValue('useTwitter'))
$info .= Yii::t('module_socialposting', 'Go to link for register Twitter application - {link}', array('{link}' => CHtml::link('https://dev.twitter.com/apps/new', 'https://dev.twitter.com/apps/new', array('target' => '_blank')))) . '<br />';
//if (!SocialpostingModel::getSocialParamValue('useVkontakte')) {
$info .= Yii::t('module_socialposting', 'Go to link for register VK.com application - {link}', array('{link}' => CHtml::link('http://vk.com/editapp?act=create&site=1', 'http://vk.com/editapp?act=create&site=1', array('target' => '_blank')))) . '<br />';
$vkApId = SocialpostingModel::getSocialParamValue('vkontakteApplicationId') ? SocialpostingModel::getSocialParamValue('vkontakteApplicationId') : 'YOUR_APPLICATION_ID';
$infoHelp .= Yii::t('module_socialposting', 'Get a Token for VK.com - {link}', array('{link}' => CHtml::link('http://oauth.vk.com/authorize?client_id=' . $vkApId . '&scope=wall,offline,photos&redirect_uri=http://oauth.vk.com/blank.html&response_type=token', 'http://oauth.vk.com/authorize?client_id=' . $vkApId . '&scope=wall,offline,photos&redirect_uri=http://oauth.vk.com/blank.html&response_type=token', array('target' => '_blank'))));
//}
if ($info) {
    Yii::app()->user->setFlash('info', $info);
}
if ($infoHelp) {
    Yii::app()->user->setFlash('warning', $infoHelp);
}
$this->widget('CustomGridView', array('dataProvider' => $model->search(), 'filter' => $model, 'afterAjaxUpdate' => 'function(){$("a[rel=\'tooltip\']").tooltip(); $("div.tooltip-arrow").remove(); $("div.tooltip-inner").remove();}', 'id' => 'socialposting-table', 'columns' => array(array('header' => tt('Section'), 'value' => 'tt($data->section)', 'filter' => CHtml::dropDownList('section_filter', $currentSection, $this->getSections())), array('header' => tt('Setting'), 'value' => '$data->title', 'type' => 'raw', 'htmlOptions' => array('class' => 'width250')), array('name' => 'value', 'type' => 'raw', 'value' => 'SocialpostingModel::getAdminValue($data)', 'htmlOptions' => array('class' => 'width150'), 'filter' => false, 'sortable' => false), array('class' => 'bootstrap.widgets.TbButtonColumn', 'template' => '{update}', 'buttons' => array('update' => array('visible' => 'SocialpostingModel::getVisible($data->type)', 'click' => 'js: function() { updateConfig($(this).attr("href")); return false; }'))))));
?>

<?php 
$this->beginWidget('bootstrap.widgets.TbModal', array('id' => 'myModal'));
?>

<div id="form_param"></div>

<div class="modal-footer">
    <a href="#" class="btn btn-primary" onclick="saveChanges(); return false;"><?php 
Esempio n. 4
0
 public function afterSave()
 {
     if ($this->scenario == 'savecat') {
         $this->saveCategories();
         if ($this->metroStations) {
             $this->setMetroStations($this->metroStations);
         }
     }
     if ($this->panoramaFile) {
         $panorama = new ApartmentPanorama();
         $panorama->fileInstance = $this->panoramaFile;
         $panorama->apartment_id = $this->id;
         $panorama->save();
     }
     if (issetModule('seo') && param('genFirendlyUrl')) {
         SeoFriendlyUrl::getAndCreateForModel($this);
     }
     if (issetModule('socialposting') && $this->active == self::STATUS_ACTIVE && ($this->owner_active = self::STATUS_ACTIVE)) {
         SocialpostingModel::preparePosting($this);
     }
     $sql = 'DELETE FROM {{apartment}} WHERE active=:draft AND date_created<DATE_SUB(NOW(),INTERVAL 1 DAY)';
     Yii::app()->db->createCommand($sql)->execute(array(':draft' => self::STATUS_DRAFT));
     return parent::afterSave();
 }