Example #1
0
 /**
  * The resume application handler.
  * 
  * @access public
  * @return string The JSON response.
  */
 public function app()
 {
     $response = array('result' => 0, 'posted' => 0);
     if (Request::get('Name') && Request::get('Email') && Request::get('Phone') && !Request::get('Message')) {
         $response['posted'] = 1;
         $Resume = new Resume();
         $Resume->setPost($_POST);
         $fields = Error::test($Resume);
         if (count($fields)) {
             $response['msg'] = 'Неверно заполнены поля: ' . implode(', ', $fields);
         } else {
             $Resume->Id = rand(1, 1000000);
             if (!empty($_FILES['file']['tmp_name'])) {
                 File::upload($Resume, $_FILES['file']);
             }
             $Email = new Email_Resume($Resume);
             if ($Email->send()) {
                 $response['result'] = 1;
             } else {
                 $response['msg'] = 'Ошибка отправки e-mail';
             }
             File::detach($Resume);
         }
     }
     return $this->outputJSON($response);
 }
Example #2
0
 /**
  * @see parent::drop()
  */
 public function drop()
 {
     if (parent::drop()) {
         File::detach($this);
         return true;
     }
     return false;
 }
Example #3
0
 /**
  * @see parent::drop()
  */
 public function drop()
 {
     if (parent::drop()) {
         File::detach($this);
         $Document = new Proud_Document();
         foreach ($Document->findList(array('ProudId = ' . $this->Id)) as $Document) {
             $Document->drop();
         }
         $Example = new Proud_Example();
         foreach ($Example->findList(array('ProudId = ' . $this->Id)) as $Example) {
             $Example->drop();
         }
         $Image = new Proud_Image();
         foreach ($Image->findList(array('ProudId = ' . $this->Id)) as $Image) {
             $Image->drop();
         }
         $Model = new Proud_Model();
         foreach ($Model->findList(array('ProudId = ' . $this->Id)) as $Model) {
             $Model->drop();
         }
         $Unit = new Proud_Unit();
         foreach ($Unit->findList(array('ProudId = ' . $this->Id)) as $Unit) {
             $Unit->drop();
         }
         return true;
     }
     return false;
 }
Example #4
0
 /**
  * The function shows edit form and saves data on submit.
  * 
  * @access protected
  * @param object $Object The object.
  * @return string The HTML code.
  */
 protected function initForm(Object $Object, $method = 'edit')
 {
     $error = array();
     if (isset($_POST['submit'])) {
         $Object->setPost($_POST);
         //$fields = Locale::translate( Error::test( $Object ) );
         if (count($fields)) {
             $error[] = 'Неверно заполнены поля: ' . implode(', ', Locale::translate($fields));
         } else {
             if ($Object->save()) {
                 if (!empty($_FILES['file']['tmp_name'])) {
                     if (File::upload($Object, $_FILES['file'])) {
                         $Object->save();
                     } else {
                         if ($this->dropOnFailedUpload($Object)) {
                             $Object->drop();
                         }
                     }
                 }
                 if (!empty($_POST['detach'])) {
                     if (File::detach($Object)) {
                         $Object->save();
                     }
                 }
                 return $this->haltForm($Object, $method);
             } else {
                 $error[] = 'Ошибка базы данных: ' . $Object->getError();
             }
         }
     }
     $name = $this->getAliasName($method) ? $this->getAliasName($method) : $this->getModelName($method);
     $this->getView()->set($name, $Object);
     $this->getView()->set('Error', $error);
     return $this->getView()->render();
 }
Example #5
0
 /**
  * @see parent::drop()
  */
 public function drop()
 {
     if (parent::drop()) {
         File::detach($this);
         foreach ($this->getItems() as $Item) {
             $Item->drop();
         }
         return true;
     }
     return false;
 }
Example #6
0
 /**
  * @see parent::drop()
  */
 public function drop()
 {
     if (parent::drop()) {
         File::detach($this);
         $Tag = new Article_Tag();
         $Tag->dropList(array('ArticleId = ' . $this->Id));
         return true;
     }
     return false;
 }
Example #7
0
 /**
  * The function shows block edit from and saves data on submit
  * 
  * @access private
  * @param object $Page The Content Page object.
  * @param string $action The action.
  * @param int $id The block id.
  * @return string The HTML code.
  */
 private function initBlock(Content_Page $Page, $action, $id = null)
 {
     $Block = new Content_Page_Block();
     if ($id) {
         $Block = $Block->findItem(array('Id = ' . $id));
     }
     if ($action == 'delete') {
         $response = array('result' => 0);
         if ($Block->Id) {
             if ($Block->drop()) {
                 $response['result'] = 1;
             } else {
                 $response['msg'] = 'Не могу удалить данные';
             }
         } else {
             $response['msg'] = 'Блок текста не найден';
         }
         return $this->outputJSON($response);
     }
     if (isset($_POST['submit'])) {
         $Block->PageId = $Page->Id;
         $Block->setPost($_POST);
         $fields = Error::test($Page);
         if (!$Block->Position) {
             foreach ($Block->findList(array(), 'Position desc', 0, 1) as $Item) {
                 $Block->Position = $Item->Position + 1;
             }
             if (!$Block->Position) {
                 $Block->Position = 1;
             }
         }
         if (count($fields)) {
             $this->getView()->set('Error', 'Неверно заполены поля: ' . implode(', ', $fields));
         } else {
             if ($Block->save()) {
                 if (!empty($_FILES['file']['tmp_name'])) {
                     if (File::upload($Block, $_FILES['file'])) {
                         $Block->save();
                     }
                 }
                 if (!empty($_POST['detach'])) {
                     if (File::detach($Block)) {
                         $Block->save();
                     }
                 }
                 $this->halt('edit/' . $Page->Id);
             } else {
                 $this->getView()->set('Error', 'Ошибка записи данных');
             }
         }
     }
     $this->getView()->set('Page', $Page);
     $this->getView()->set('Block', $Block);
     $this->getView()->setMethod('block');
     return $this->getView()->render();
 }