當前位置: 首頁>>代碼示例>>PHP>>正文


PHP blogPostModel::getFieldsById方法代碼示例

本文整理匯總了PHP中blogPostModel::getFieldsById方法的典型用法代碼示例。如果您正苦於以下問題:PHP blogPostModel::getFieldsById方法的具體用法?PHP blogPostModel::getFieldsById怎麽用?PHP blogPostModel::getFieldsById使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在blogPostModel的用法示例。


在下文中一共展示了blogPostModel::getFieldsById方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: execute

 public function execute()
 {
     $data = waRequest::post('data', null);
     if (!$data) {
         return;
     }
     foreach ($data as $name => $value) {
         if (in_array($name, $this->allowed_fields) === false) {
             throw new waException("Can't update post: editing of this field is denied");
         }
         if ($name == 'status') {
             if (in_array($value, array(blogPostModel::STATUS_DRAFT, blogPostModel::STATUS_DEADLINE, blogPostModel::STATUS_SCHEDULED, blogPostModel::STATUS_PUBLISHED)) === false) {
                 throw new waException("Can't change status: unknown value");
             }
         }
     }
     $post_id = waRequest::post('post_id', null, waRequest::TYPE_INT);
     $post_model = new blogPostModel();
     $post = null;
     if ($post_id) {
         $post = $post_model->getFieldsById($post_id, array('id', 'blog_id', 'contact_id', 'datetime'));
     }
     if (!$post) {
         throw new waException("Unknown post");
     }
     $contact = wa()->getUser();
     $contact_id = $contact->getId();
     $allow = blogHelper::checkRights($post['blog_id'], $contact_id, $contact_id != $post['contact_id'] ? blogRightConfig::RIGHT_FULL : blogRightConfig::RIGHT_READ_WRITE);
     if (!$allow) {
         throw new waException("Access denied");
     }
     if (!$post_model->updateById($post_id, $data)) {
         throw new waException("Error when updating data");
     }
     $post = array_merge($post, $data);
     if ($post['status'] == blogPostModel::STATUS_DEADLINE) {
         $user = wa()->getUser();
         $timezone = $user->getTimezone();
         $current_datetime = waDateTime::date("Y-m-d", null, $timezone);
         $datetime = waDateTime::date("Y-m-d", $post['datetime'], $timezone);
         if ($datetime <= $current_datetime) {
             $post['overdue'] = true;
         }
     }
     $this->response['post'] = $post;
 }
開發者ID:Lazary,項目名稱:webasyst,代碼行數:46,代碼來源:blogPostSaveField.controller.php

示例2: execute

 public function execute()
 {
     $this->getResponse()->addHeader('Content-type', 'application/json');
     $post_id = waRequest::post('post_id', null);
     $date = waRequest::post('date');
     if (!is_null($post_id)) {
         $post_model = new blogPostModel();
         $post = $post_model->getFieldsById($post_id, array('status'));
         $status = $post['status'];
         if ($status == blogPostModel::STATUS_DEADLINE || $status == blogPostModel::STATUS_DRAFT) {
             if (strlen($date) == 0) {
                 $this->response['valid'] = true;
                 return;
             }
         }
     }
     $this->response['valid'] = true;
     if (!waDateTime::parse('date', $date, wa()->getUser()->getTimezone())) {
         $this->response['valid'] = false;
     }
 }
開發者ID:cjmaximal,項目名稱:webasyst-framework,代碼行數:21,代碼來源:blogPostValidateDate.controller.php

示例3: delete

 private function delete($post)
 {
     $post_model = new blogPostModel();
     $post = $post_model->getFieldsById($post['id'], array('id', 'blog_id'));
     if ($post) {
         if (!$this->getUser()->isAdmin($this->getApp())) {
             // author of post
             if ($post['contact_id'] == $this->getUser()->getId()) {
                 blogHelper::checkRights($post['blog_id'], $this->getUser()->getId(), blogRightConfig::RIGHT_READ_WRITE);
             } else {
                 blogHelper::checkRights($post['blog_id'], $this->getUser()->getId(), blogRightConfig::RIGHT_FULL);
             }
         }
         $post_model->deleteById($post['id']);
         $this->response['redirect'] = '?blog=' . $post['blog_id'];
     } else {
         $this->response['redirect'] = '?';
     }
 }
開發者ID:navi8602,項目名稱:wa-shop-ppg,代碼行數:19,代碼來源:blogPostSave.controller.php


注:本文中的blogPostModel::getFieldsById方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。