Example #1
0
 public function deactivation($page_id = null)
 {
     $result = false;
     // доступно дл¤ пользователей первой роли (например, Ђ–еактивуї)
     $role_id = Users::model()->findByPk(Yii::app()->user->id)->role_id;
     if ($role_id < 2 && !is_null($page_id) && Pages::model()->existsPage($page_id)) {
         $link_id = ModulesInPages::model()->getLink($page_id, $this->id);
         if ($link_id) {
             $result = ModuleFieldsFiles::model()->deactivation($link_id, $this->id);
         }
     }
     return $result;
 }
Example #2
0
 public function actionDeactivation($page_id = null)
 {
     $result = false;
     // доступно для пользователей первой роли (например, «Реактиву»)
     $role_id = Users::model()->findByPk(Yii::app()->user->id)->role_id;
     if ($role_id < 2 && !is_null($page_id) && Pages::model()->existsPage($page_id)) {
         $link_id = ModulesInPages::model()->getLink($page_id, $this->module->id);
         if ($link_id) {
             $result = ModuleFieldsFiles::model()->deactivation($link_id, $this->module->id);
         }
     }
     if ($result) {
         $this->redirect(Yii::app()->baseUrl . '?r=pages/update&id=' . $page_id . '&/#!/tab_fourth');
     } else {
         $this->redirect(Yii::app()->request->baseUrl . '/admin.php');
     }
 }
Example #3
0
 protected function update_value_of_item($id, $file_id, $page_id)
 {
     $out = true;
     $data = array('file_id' => $file_id);
     if (!is_null($page_id) && Pages::model()->existsPage($page_id)) {
         $link_id = ModulesInPages::model()->getLink((int) $page_id, $this->module_id);
         if (!is_null($id) && ModuleFieldsFiles::model()->existsItem($link_id, $id)) {
             $model = ModuleFieldsFiles::model()->findByPk($id);
             if (isset($data)) {
                 $old_file_id = $model->file_id;
                 if ($data['file_id'] == 'NULL') {
                     $data['file_id'] = '';
                 }
                 if ((int) $old_file_id && (int) $old_file_id != (int) $data['file_id']) {
                     $data['link'] = NULL;
                     $data['extension'] = NULL;
                     $data['size'] = 0;
                 }
                 if ((int) $data['file_id']) {
                     $file_name = Files::model()->findByPk($data['file_id'])->file_name;
                     $data['link'] = '/upload/' . md5($this->module_id) . '/' . $file_name;
                     $data['extension'] = explode('.', $file_name);
                     $data['extension'] = $data['extension'][count($data['extension']) - 1];
                     $data['size'] = round(filesize($_SERVER['DOCUMENT_ROOT'] . rawurldecode($data['link'])) / 1024);
                 }
                 $data['date_time'] = date('Y-m-d H:i:s');
                 $model->attributes = $data;
                 if ($model->save()) {
                     if ((int) $old_file_id && (int) $old_file_id != (int) $data['file_id']) {
                         Files::model()->deleteFile($old_file_id, $this->module_id);
                     }
                     Files::model()->saveTempFile((int) $data['file_id']);
                 } else {
                     $out = false;
                 }
             } else {
                 $out = false;
             }
         } else {
             $out = false;
         }
     } else {
         $out = false;
     }
     return $out;
 }
Example #4
0
    if (Yii::app()->user->hasFlash($this->module_id . '_add_message')) {
        echo Yii::app()->user->getFlash($this->module_id . '_add_message');
    }
    ?>
		<?php 
    $this->endWidget();
    ?>
		</div>
	</div>
	<?php 
}
?>
	<div class="catalog">
		<?php 
$mpage_id = ModulesInPages::model()->getLink($page_id, $this->module_id);
$data = ModuleFieldsFiles::model()->getList($mpage_id);
if (count($data) > 0) {
    ?>
			<form method="POST" action="/admin.php?r=pages/update&id=<?php 
    echo $page_id;
    ?>
&/#!/tab_<?php 
    echo $this->module_id;
    ?>
">
				<ul class="<?php 
    echo count($data) > 1 && $role_id < 2 ? 'sortable' : '';
    ?>
 type_3">
				<?php 
    foreach ($data as $item_id => $item) {