Commit 2c1a87c3 authored by difox's avatar difox

Merge branch 'master' of http://git.task-on.com/ktask/task-on.com

Conflicts:
	frontend/web/css/custom.css
parents bdddd071 a5839d85
...@@ -118,6 +118,19 @@ class UnisenderAPI { ...@@ -118,6 +118,19 @@ class UnisenderAPI {
); );
} }
/**
* @param $email
* @return array
*/
public function validateSender($email){
return $this->callMethod(
'validateSender',
[
'email' => $email
]
);
}
/** /**
* @param array $Params * @param array $Params
* @return string * @return string
......
...@@ -12,7 +12,7 @@ class MetaTagBehavior extends Behavior ...@@ -12,7 +12,7 @@ class MetaTagBehavior extends Behavior
return [ return [
ActiveRecord::EVENT_AFTER_UPDATE => 'Save', ActiveRecord::EVENT_AFTER_UPDATE => 'Save',
ActiveRecord::EVENT_AFTER_INSERT => 'Insert', ActiveRecord::EVENT_AFTER_INSERT => 'Insert',
ActiveRecord::EVENT_AFTER_DELETE => 'Delete', ActiveRecord::EVENT_BEFORE_DELETE => 'Delete',
]; ];
} }
...@@ -69,10 +69,13 @@ class MetaTagBehavior extends Behavior ...@@ -69,10 +69,13 @@ class MetaTagBehavior extends Behavior
public function Delete($event) public function Delete($event)
{ {
MetaTags::deleteAll([ if($this->owner->metaTags)
'object_id' => $this->owner->id, {
'model_id' => get_class($this->owner) foreach ($this->owner->metaTags as $meta)
]); {
$meta->delete();
}
}
return true; return true;
} }
......
...@@ -13,7 +13,7 @@ class CoBlocksLangBehavior extends Behavior ...@@ -13,7 +13,7 @@ class CoBlocksLangBehavior extends Behavior
return [ return [
ActiveRecord::EVENT_AFTER_UPDATE => 'Save', ActiveRecord::EVENT_AFTER_UPDATE => 'Save',
ActiveRecord::EVENT_AFTER_INSERT => 'Insert', ActiveRecord::EVENT_AFTER_INSERT => 'Insert',
ActiveRecord::EVENT_AFTER_DELETE => 'Delete', ActiveRecord::EVENT_BEFORE_DELETE => 'Delete',
]; ];
} }
...@@ -67,9 +67,13 @@ class CoBlocksLangBehavior extends Behavior ...@@ -67,9 +67,13 @@ class CoBlocksLangBehavior extends Behavior
public function Delete($event) public function Delete($event)
{ {
CoBlocksLang::deleteAll([ if($this->owner->langs)
'block_id' => $this->owner->id {
]); foreach ($this->owner->langs as $lang)
{
$lang->delete();
}
}
return true; return true;
} }
......
...@@ -13,7 +13,7 @@ class CoContentLangBehavior extends Behavior ...@@ -13,7 +13,7 @@ class CoContentLangBehavior extends Behavior
return [ return [
ActiveRecord::EVENT_AFTER_UPDATE => 'Save', ActiveRecord::EVENT_AFTER_UPDATE => 'Save',
ActiveRecord::EVENT_AFTER_INSERT => 'Insert', ActiveRecord::EVENT_AFTER_INSERT => 'Insert',
ActiveRecord::EVENT_AFTER_DELETE => 'Delete', ActiveRecord::EVENT_BEFORE_DELETE => 'Delete',
]; ];
} }
...@@ -67,9 +67,13 @@ class CoContentLangBehavior extends Behavior ...@@ -67,9 +67,13 @@ class CoContentLangBehavior extends Behavior
public function Delete($event) public function Delete($event)
{ {
CoContentLang::deleteAll([ if($this->owner->langs)
'content_id' => $this->owner->id {
]); foreach ($this->owner->langs as $lang)
{
$lang->delete();
}
}
return true; return true;
} }
......
...@@ -28,7 +28,7 @@ class ContentAdminController extends AdminController ...@@ -28,7 +28,7 @@ class ContentAdminController extends AdminController
'Update' => 'Редактирование контента', 'Update' => 'Редактирование контента',
'Delete' => 'Удаление контента', 'Delete' => 'Удаление контента',
'View' => 'Просмотр контента', 'View' => 'Просмотр контента',
// 'Copy' => '', 'Copy' => 'Копирование страниц',
]; ];
} }
...@@ -44,23 +44,6 @@ class ContentAdminController extends AdminController ...@@ -44,23 +44,6 @@ class ContentAdminController extends AdminController
]; ];
} }
// public function actionCopy($id)
// {
// $model = $this->findModel($id);
// $meta = $model->metaTags->attributes;
// \Yii::$app->request->setBodyParams(['MetaTags' => $meta]);
// $newPage = new CoContent();
// $data = $model->attributes;
// unset($data['id']);
// $data['url'] = '';
// $newPage->setAttributes($data);
// $newPage->name .= ' (Копия)';
// $newPage->save(false);
// $this->redirect(['manage']);
// }
/** /**
* Lists all CoContent models. * Lists all CoContent models.
* @return mixed * @return mixed
...@@ -256,6 +239,62 @@ class ContentAdminController extends AdminController ...@@ -256,6 +239,62 @@ class ContentAdminController extends AdminController
return $this->redirect(['manage']); return $this->redirect(['manage']);
} }
public function actionCopy($id)
{
$model = $this->findModel($id);
$transaction = Yii::$app->db->beginTransaction();
try
{
$copy = new CoContent();
$data = $model->attributes;
unset($data['id']);
$copy->setAttributes($data);
$copy->save(false);
if($model->metaTags)
{
foreach ($model->metaTags as $mt)
{
$mtn = new \common\models\MetaTags;
$data = $mt->attributes;
unset($data['id']);
$mtn->setAttributes($data);
$mtn->object_id = $copy->id;
$mtn->save(false);
}
}
if($model->langs)
{
foreach ($model->langs as $lang)
{
$lng = new CoContentLang;
$data = $lang->attributes;
unset($data['id']);
$lng->setAttributes($data);
$lng->name .= ' (Копия)';
$lng->content_id = $copy->id;
$lng->save(false);
}
}
$transaction->commit();
}
catch (Exception $e)
{
$transaction->rollBack();
throw $e;
}
$this->redirect(['manage']);
}
/** /**
* Finds the CoContent model based on its primary key value. * Finds the CoContent model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown. * If the model is not found, a 404 HTTP exception will be thrown.
......
...@@ -125,7 +125,7 @@ class CoContent extends \common\components\ActiveRecordModel ...@@ -125,7 +125,7 @@ class CoContent extends \common\components\ActiveRecordModel
*/ */
public function getMetaTags($lang_id = null) public function getMetaTags($lang_id = null)
{ {
$query = $this->hasOne(MetaTags::className(), ['object_id' => 'id'])->where(['model_id' => get_class($this)]); $query = $this->hasMany(MetaTags::className(), ['object_id' => 'id'])->where(['model_id' => get_class($this)]);
if($lang_id) if($lang_id)
{ {
......
...@@ -43,15 +43,15 @@ use common\modules\content\models\CoCategory; ...@@ -43,15 +43,15 @@ use common\modules\content\models\CoCategory;
], ],
[ [
'class' => 'common\components\ColorActionColumn', 'class' => 'common\components\ColorActionColumn',
'template' => '{update} {delete}', 'template' => '{copy} {update} {delete}',
'buttons' => [ 'buttons' => [
// 'copy' => function ($url, $model, $key) { 'copy' => function ($url, $model, $key) {
// return '<a href="'.Url::toRoute(['copy', 'id' => $model->id]).'">'.Html::beginTag('i', [ return '<a href="'.Url::toRoute(['copy', 'id' => $model->id]).'">'.Html::beginTag('i', [
// 'title' => "Копировать страницу", 'title' => "Копировать страницу",
// 'data-toggle' => 'tooltip', 'data-toggle' => 'tooltip',
// 'class' => 'fa fa-copy fa-lg' 'class' => 'fa fa-copy fa-lg'
// ]) . Html::endTag('i') . '</a>'; ]) . Html::endTag('i') . '</a>';
// }, },
], ],
], ],
], ],
......
...@@ -4,6 +4,8 @@ use \yii\helpers\Json; ...@@ -4,6 +4,8 @@ use \yii\helpers\Json;
$email = 'bystrov@kupitsite.ru'; $email = 'bystrov@kupitsite.ru';
$sender = new UnisenderAPI(); $sender = new UnisenderAPI();
// Create the send list // Create the send list
$newList = $sender->createList(); $newList = $sender->createList();
...@@ -11,11 +13,17 @@ $newListObject=Json::decode($newList); ...@@ -11,11 +13,17 @@ $newListObject=Json::decode($newList);
if (array_key_exists('result', $newListObject) && array_key_exists('id', $newListObject['result'])) { if (array_key_exists('result', $newListObject) && array_key_exists('id', $newListObject['result'])) {
$newListId=$newListObject['result']['id']; $newListId=$newListObject['result']['id'];
// Subscribe user to new List // Subscribe user to new List
$sender->subscribe(['list_ids' => $newListId, 'fields' => ['email' => $email]]); $sender->subscribe(['list_ids' => $newListId, 'fields[email]' => $email]);
// Create new message // Create new message
$newMessageId=$sender->createEmailMessage('bystrov', $email, 'Testing Subject', 'Testing Body <br><a href="http://www.google.com/">Testing link</a>', $newListId); $newMessage=$sender->createEmailMessage('bystrov', $email, 'Testing Subject', 'Testing Body <br><a href="http://www.google.com/">Testing link</a><a href="{{_UnsubscribeUrl}}">Отписаться</a>', $newListId);
// Decode result
$newMessageObject=Json::decode($newMessage);
if (array_key_exists('result', $newMessageObject) && array_key_exists('message_id', $newMessageObject['result'])) {
// Get the message ID
$newMessageId=$newMessageObject['result']['message_id'];
// Create new campaign // Create new campaign
$newCampaign = $sender->createCampaign($newMessageId); $newCampaign = $sender->createCampaign($newMessageId);
}
} }
echo 'Рассылка: '.((isset($newCampaign)) ? $newCampaign : 'Not found'); echo 'Рассылка: '.((isset($newCampaign)) ? $newCampaign : 'Not found');
......
...@@ -27,3 +27,20 @@ ...@@ -27,3 +27,20 @@
.eauth-list .eauth-service-link:before, .eauth-service-link:after { .eauth-list .eauth-service-link:before, .eauth-service-link:after {
background: url("/images/auth.png") 0 0 no-repeat; background: url("/images/auth.png") 0 0 no-repeat;
} }
section .container ul:not([class]),
section .container ul:not([class]) li,
section .container ol:not([class]),
section .container ol:not([class]) li {
list-style: inherit;
}
section .container ul:not([class]),
section .container ol:not([class]) {
padding: 0 0 0 20px;
list-style-type: decimal;
}
section .container ul:not([class]) li,
section .container ol:not([class]) li {
margin: 0 0 15px 0;
color: #2d323a;
}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment