Пример #1
0
 public function actionDelete()
 {
     $page = Folder::model()->findByPk(Yii::app()->request->getParam('id'));
     if ($page !== null) {
         $page->delete();
     }
     $this->redirect(Yii::app()->createUrl('//documents/admin'));
 }
Пример #2
0
 protected function beforeSave()
 {
     $folderModel = Folder::model()->findByPk($this->folder_id);
     $existingBookmarkModel = Bookmark::model()->findSingleByAttributes(array('user_id' => \GO::user()->id, 'folder_id' => $folderModel->id));
     if (!empty($existingBookmarkModel)) {
         throw new \Exception(str_replace('%fn', $folderModel->name, \GO::t('bookmarkAlreadyExists', 'files')));
     }
     return parent::beforeSave();
 }
Пример #3
0
 public function NameUnique()
 {
     $m = Folder::model()->findByAttributes(array('name' => $this->name));
     echo "<pre>";
     // print_r($m);
     if (isset($m)) {
         $this->addError("Name", "User with this name already exist and is active.");
     }
 }
 public function run()
 {
     $folder = array();
     $command = Yii::app()->db->createCommand("SELECT DISTINCT document.folder_id as id  FROM `content` LEFT JOIN document ON content.object_id = document.id WHERE content.`object_model`='Document' AND content.space_id=" . Yii::app()->controller->space->id)->queryAll();
     if (sizeof($command) > 0) {
         $id = array();
         foreach ($command as $one) {
             $id[] = $one['id'];
         }
         $folder = Folder::model()->findAllByPk($id);
         $this->render('folderPanel', array('folder' => $folder));
     }
 }
 public function testQuoting()
 {
     $this->assertEmpty(Folder::model()->findByPk("'"));
     $this->assertEmpty(Folder::model()->ancestorsOf("'")->findAll());
     $this->assertEmpty(Folder::model()->childrenOf("'")->findAll());
     $this->assertEmpty(Folder::model()->parentOf("'")->findAll());
     $this->assertEmpty(Folder::model()->deleteNode("'"));
     $this->assertEmpty(Folder::model()->descendantsOf("'")->findAll());
     $this->assertEmpty(Folder::model()->fullPathOf("'")->findAll());
     $this->assertEmpty(Folder::model()->pathOf("'")->findAll());
     $this->assertEmpty(Folder::model()->unorderedPathOf("'")->findAll());
     /** @var Folder $folder5 */
     $folder5 = Folder::model()->findByPk(5);
     try {
         $folder5->moveTo("'");
         $this->fail();
     } catch (CDbException $e) {
         $this->assertEquals(201, $e->getCode());
     }
     $newFolder = new Folder();
     $newFolder->name = 'Folder';
     $this->assertTrue($newFolder->save());
     $this->assertEquals(1, $newFolder->appendTo("'"));
     try {
         Folder::model()->markAsRoot("'");
         $this->fail();
     } catch (CDbException $e) {
         // http://dev.mysql.com/doc/refman/5.5/en/error-messages-server.html
         $this->assertEquals('1452', $e->errorInfo[1]);
     }
 }
Пример #6
0
<?php

echo CHtml::textArea("name", "", array('id' => 'contentForm_question', 'class' => 'form-control autosize contentForm', 'rows' => '1', "tabindex" => "1", "placeholder" => Yii::t('DocumentsModule.widgets_views_pollForm', "Ask something...")));
?>

<div class="contentForm_options">
    <?php 
echo CHtml::textArea("body", "", array('id' => "contentForm_answersText", 'rows' => '5', 'style' => 'height: auto !important;', "class" => "form-control contentForm", "tabindex" => "2", "placeholder" => Yii::t('DocumentsModule.widgets_views_pollForm', "Possible answers (one per line)")));
?>
</div>

<div class="contentForm_options">
    <?php 
$models = Folder::model()->findAll();
?>

    <?php 
echo CHtml::dropDownList('selectFolder', 'name', CHtml::listData($models, 'id', 'name'), array('empty' => Yii::t('DocumentsModule.widgets_views_pollForm', "Select a folder"), 'class' => 'form-control contentForm'));
?>
</div>