-
Notifications
You must be signed in to change notification settings - Fork 2
Home
Shohei Nakajima edited this page Sep 14, 2015
·
20 revisions
ワークフローに関連するプラグイン。
コンテンツのワークフロー関連で使用するコンポーネント。
const STATUS_PUBLISHED = '1';
const STATUS_APPROVED = '2';
const STATUS_IN_DRAFT = '3';
const STATUS_DISAPPROVED = '4';
登録アクションでリクエストパラメータ(request->data)からステータスをパースするメソッド
(例)
if ($this->request->isPost() || $this->request->isPut()) {
$data = $this->data;
$data['Announcement']['status'] = $this->Workflow->parseStatus();
unset($data['Announcement']['id']);
if ($this->Announcement->saveAnnouncement($data)) {
$this->redirect(NetCommonsUrl::backToPageUrl());
return;
}
$this->NetCommons->handleValidationError($this->Announcement->validationErrors);
} else {
if (! $this->request->data = $this->Announcement->getAnnouncement()) {
$this->request->data = $this->Announcement->createAll();
}
$this->request->data['Frame'] = Current::read('Frame');
}
ブロックのパーミッションを取得するメソッド。主にブロックの権限設定で使用する
後で、リンク張る
上記以外は、Workflow/Controller/Component/WorkflowComponent.phpを参照して下さい。
public $actsAs = array(
'Workflow.Workflow',
);
(例)
$conditions = array(
'FaqQuestion.faq_id' => $this->viewVars['faq']['id'],
);
if (isset($this->params['named']['category_id'])) {
$conditions['FaqQuestion.category_id'] = $this->params['named']['category_id'];
}
//取得
$faqQuestions = $this->FaqQuestion->getWorkflowContents('all', array(
'recursive' => 0,
'conditions' => $conditions
));
権限によって、コンテンツの閲覧できる条件(conditionsのみ)を取得する
$query['conditions'] = $this->BbsArticle->getWorkflowConditions(array(
'BbsArticleTree.parent_id' => null,
'BbsArticle.bbs_id' => $this->viewVars['bbs']['id'],
));
コンテンツのステータスに関するバリデーションを設定する。各プラグインは何もする必要はない。
ビヘイビアを設定したModelに対して、ワークフロー関連のフィールドのデータを更新する。各プラグインは何もする必要はない。
- WorkflowBehavior::canReadWorkflowContent()
・・・コンテンツの閲覧権限チェック - WorkflowBehavior::canCreateWorkflowContent()
・・・コンテンツの作成権限チェック - WorkflowBehavior::canEditWorkflowContent()
・・・コンテンツの編集権限チェック - WorkflowBehavior::canDeleteWorkflowContent()
・・・コンテンツの削除権限チェック(※一度でも公開した場合は、公開権限があるユーザのみ削除可能とする)