本文整理汇总了PHP中Workflow::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Workflow::model方法的具体用法?PHP Workflow::model怎么用?PHP Workflow::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Workflow
的用法示例。
在下文中一共展示了Workflow::model方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadModel
public function loadModel($id)
{
$model = Workflow::model()->findByPk((int) $id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例2: actionRoleException
/**
* Create a workflow based exception for a role.
*
* This method is called by a form on the {@link AdminController::manageRoles}
* page to allow for the creation of workflow based exceptions for a role.
* Workflow exceptions modify which fields are visible or editable based on
* what stage of a workflow a contact is in.
*/
public function actionRoleException()
{
$model = new Roles();
$temp = Workflow::model()->findAll();
$workflows = array();
foreach ($temp as $workflow) {
$workflows[$workflow->id] = $workflow->name;
}
$roleInput = filter_input(INPUT_POST, 'Roles', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
if (!empty($roleInput)) {
$workflowId = filter_input(INPUT_POST, 'workflow', FILTER_SANITIZE_NUMBER_INT);
if (!empty($workflowId)) {
$workflowName = Workflow::model()->findByPk($workflowId)->name;
} else {
$this->redirect('manageRoles');
}
$stage = $_POST['workflowStages'];
if (isset($stage) && !empty($stage)) {
$stageName = X2Model::model('WorkflowStage')->findByAttributes(array('workflowId' => $workflow, 'stageNumber' => $stage))->name;
} else {
$this->redirect('manageRoles');
}
if (!isset($_POST['viewPermissions'])) {
$viewPermissions = array();
} else {
$viewPermissions = $_POST['viewPermissions'];
}
if (!isset($_POST['editPermissions'])) {
$editPermissions = array();
} else {
$editPermissions = $_POST['editPermissions'];
}
$model->attributes = $_POST['Roles'];
$model->timeout *= 60;
$oldRole = Roles::model()->findByAttributes(array('name' => $model->name));
$model->users = "";
$model->name .= " - {$workflowName}: {$stageName}";
if ($model->save()) {
$replacement = new RoleToWorkflow();
$replacement->workflowId = $workflow;
$replacement->stageId = $stage;
$replacement->roleId = $oldRole->id;
$replacement->replacementId = $model->id;
$replacement->save();
$fields = Fields::model()->findAll();
$temp = array();
foreach ($fields as $field) {
$temp[] = $field->id;
}
$both = array_intersect($viewPermissions, $editPermissions);
$view = array_diff($viewPermissions, $editPermissions);
$neither = array_diff($temp, $viewPermissions);
foreach ($both as $field) {
$rolePerm = new RoleToPermission();
$rolePerm->roleId = $model->id;
$rolePerm->fieldId = $field;
$rolePerm->permission = 2;
$rolePerm->save();
}
foreach ($view as $field) {
$rolePerm = new RoleToPermission();
$rolePerm->roleId = $model->id;
$rolePerm->fieldId = $field;
$rolePerm->permission = 1;
$rolePerm->save();
}
foreach ($neither as $field) {
$rolePerm = new RoleToPermission();
$rolePerm->roleId = $model->id;
$rolePerm->fieldId = $field;
$rolePerm->permission = 0;
$rolePerm->save();
}
}
$this->redirect('manageRoles');
}
}
示例3: actionUpload
public function actionUpload()
{
parent::actionUpload();
$folder = $_SERVER['DOCUMENT_ROOT'] . Yii::app()->request->baseUrl . '/upload/';
// folder for uploaded files
$file = $folder . basename($_FILES['uploadfile']['name']);
if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $file)) {
$row = 0;
if (($handle = fopen($file, "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
if ($row > 0) {
$model = Wfstatus::model()->findByPk((int) $data[0]);
if ($model === null) {
$model = new Wfstatus();
}
$model->wfstatusid = (int) $data[0];
$workflow = Workflow::model()->findbyattributes(array('wfname' => $data[1]));
if ($workflow !== null) {
$model->workflowid = $workflow->workflowid;
}
$model->wfstatusname = $data[2];
$model->recordstatus = (int) $data[3];
try {
if (!$model->save()) {
$this->messages = $this->messages . Catalogsys::model()->getcatalog(' upload error at ' . $data[0]);
}
} catch (Exception $e) {
$this->messages = $this->messages . $e->getMessage();
}
}
$row++;
}
} else {
$this->messages = $this->messages . ' memory or harddisk full';
}
fclose($handle);
} else {
$this->messages = $this->messages . ' check your directory permission';
}
if ($this->messages == '') {
$this->messages = 'success';
}
echo $this->messages;
}
示例4: actionManageRoles
/**
* A catch all page for roles.
*
* This action renders a page with forms for the creation, editing, and deletion
* of roles. It also displays a grid with all user created roles (default
* roles are not included and cannot be edited this way).
*/
public function actionManageRoles()
{
$dataProvider = new CActiveDataProvider('Roles');
$roles = $dataProvider->getData();
$arr = array();
foreach ($roles as $role) {
$arr[$role->name] = $role->name;
}
$temp = Workflow::model()->findAll();
$workflows = array();
foreach ($temp as $workflow) {
$workflows[$workflow->id] = $workflow->name;
}
$model = new Roles();
$model->timeout = 60;
if (isset($_POST['Roles'])) {
$model->attributes = $_POST['Roles'];
if (!isset($_POST['viewPermissions'])) {
$viewPermissions = array();
} else {
$viewPermissions = $_POST['viewPermissions'];
}
if (!isset($_POST['editPermissions'])) {
$editPermissions = array();
} else {
$editPermissions = $_POST['editPermissions'];
}
if (isset($_POST['Roles']['users'])) {
$users = $model->users;
} else {
$users = array();
}
$model->users = "";
$model->timeout *= 60;
if ($model->save()) {
foreach ($users as $user) {
$role = new RoleToUser();
$role->roleId = $model->id;
if (!is_numeric($user)) {
$userRecord = User::model()->findByAttributes(array('username' => $user));
$role->userId = $userRecord->id;
$role->type = 'user';
} else {
$role->userId = $user;
$role->type = 'group';
}
/* end x2temp */
$role->save();
}
$fields = Fields::model()->findAll();
$temp = array();
foreach ($fields as $field) {
$temp[] = $field->id;
}
$both = array_intersect($viewPermissions, $editPermissions);
$view = array_diff($viewPermissions, $editPermissions);
$neither = array_diff($temp, $viewPermissions);
foreach ($both as $field) {
$rolePerm = new RoleToPermission();
$rolePerm->roleId = $model->id;
$rolePerm->fieldId = $field;
$rolePerm->permission = 2;
$rolePerm->save();
}
foreach ($view as $field) {
$rolePerm = new RoleToPermission();
$rolePerm->roleId = $model->id;
$rolePerm->fieldId = $field;
$rolePerm->permission = 1;
$rolePerm->save();
}
foreach ($neither as $field) {
$rolePerm = new RoleToPermission();
$rolePerm->roleId = $model->id;
$rolePerm->fieldId = $field;
$rolePerm->permission = 0;
$rolePerm->save();
}
} else {
foreach ($model->getErrors() as $err) {
$errors = $err;
}
$errors = implode(',', $errors);
Yii::app()->user->setFlash('error', Yii::t('admin', "Unable to save role: {errors}", array('{errors}' => $errors)));
}
$this->redirect('manageRoles');
}
$this->render('manageRoles', array('dataProvider' => $dataProvider, 'model' => $model, 'roles' => $arr, 'workflows' => $workflows));
}
示例5: actionGetStageValue
public function actionGetStageValue($id, $stage, $users, $modelType, $start, $end)
{
$modelType = self::parseModelType($modelType);
$dateRange = self::getDateRange();
$expectedCloseDateDateRange = self::getDateRange('expectedCloseDateStart', 'expectedCloseDateEnd', 'expectedCloseDateRange');
$workflow = Workflow::model()->findByPk($id);
if ($workflow !== null) {
list($totalValue, $projectedValue, $currentAmount, $count) = Workflow::getStageValue($id, $stage, $users, $modelType, $dateRange, $expectedCloseDateDateRange);
$this->renderPartial('_dataSummary', array('stageName' => $workflow->getStageName($stage), 'totalValue' => Formatter::formatCurrency($totalValue), 'projectedValue' => Formatter::formatCurrency($projectedValue), 'currentAmount' => Formatter::formatCurrency($currentAmount), 'count' => $count));
}
}
示例6: getWorkflowStatus
/**
* Retrieves information on all stages (their complete state, their stage dependencies,
* their stage permissions, and their comment requirements) and on the workflow itself
* (its complete and started state and its id)
* @param int $workflowId id of workflow
* @param int $modelId id of model to which the workflow is related (optional)
* @param mixed $modelType type of model to which the workflow is related.
* @return array Contains information about the workflow and its stages
*/
public static function getWorkflowStatus($workflowId, $modelId = 0, $modelType = '')
{
$workflowStatus = array('id' => $workflowId, 'stages' => array(), 'started' => false, 'completed' => true);
$workflow = Workflow::model()->findByPk($workflowId);
if ($workflow) {
$workflowStatus['financial'] = $workflow->financial;
$workflowStatus['financialModel'] = $workflow->financialModel;
$workflowStatus['financialField'] = $workflow->financialField;
}
$workflowStages = X2Model::model('WorkflowStage')->findAllByAttributes(array('workflowId' => $workflowId), new CDbCriteria(array('order' => 'id ASC')));
// load all WorkflowStage names into workflowStatus
foreach ($workflowStages as &$stage) {
$workflowStatus['stages'][$stage->stageNumber] = array('id' => $stage->id, 'name' => $stage->name, 'requirePrevious' => $stage->requirePrevious, 'roles' => $stage->roles, 'complete' => false, 'createDate' => null, 'completeDate' => null, 'requireComment' => $stage->requireComment);
}
unset($stage);
$workflowActions = array();
if ($modelId !== 0) {
$workflowActions = X2Model::model('Actions')->findAllByAttributes(array('associationId' => $modelId, 'associationType' => $modelType, 'type' => 'workflow', 'workflowId' => $workflowId), new CDbCriteria(array('order' => 'createDate ASC')));
}
foreach ($workflowActions as &$action) {
$workflowStatus['started'] = true;
// clearly there's at least one stage up in here
if (isset($action->workflowStage)) {
$stage = $action->workflowStage->stageNumber;
// decode workflowActions into a funnel list
// Note: multiple actions with the same stage will overwrite each other
$workflowStatus['stages'][$stage]['createDate'] = $action->createDate;
$workflowStatus['stages'][$stage]['completeDate'] = $action->completeDate;
/* A stage is considered complete if either its complete attribute is true or if it
has a valid complete date. */
$workflowStatus['stages'][$stage]['complete'] = $action->complete == 'Yes' || !empty($action->completeDate) && $action->completeDate < time();
$workflowStatus['stages'][$stage]['description'] = $action->actionDescription;
}
}
// now scan through and see if there are any incomplete stages
foreach ($workflowStatus['stages'] as &$stage) {
if (!isset($stage['completeDate'])) {
$workflowStatus['completed'] = false;
break;
}
}
return $workflowStatus;
}
示例7: actionIndex
/**
* Lists all models.
*/
public function actionIndex()
{
$url = parse_url(app()->request->getHostInfo(), PHP_URL_HOST);
$currentWorkflow = $this->api('Cms.Workflow.getByUrl', array('url' => $url));
$workflowId = 0;
$workflows = array();
$workflow = $this->getWorkflow();
if (is_object($workflow)) {
$workflowId = $workflow->id;
} else {
$workflow = $currentWorkflow;
//get workflow by url
if (is_object($currentWorkflow)) {
$workflowId = $currentWorkflow->id;
}
}
//find all workflows
if (is_object($workflow)) {
//init setting params for current workflow
$this->api('Xpress.Settings.sync', array('workflowId' => $workflow->id));
$workflows = Workflow::model()->findAll('site_id=:site_id', array(':site_id' => $workflow->site_id));
if (count($workflows)) {
$workflows = CHtml::listData($workflows, 'id', 'name');
}
}
$model = new SettingParam('search');
$model->unsetAttributes();
// clear any default values
if (isset($_POST['SettingParam'])) {
$model->attributes = $_POST['SettingParam'];
} elseif (isset($_GET['module'])) {
$model->module = $_GET['module'];
if (in_array($model->module, array('Xpress', 'Admin'))) {
$model->module = 'System';
}
} else {
$model->module = 'System';
}
$model->visible = 1;
$model->workflow_id = $workflowId;
$dataProvider = $model->search();
$dataProvider->pagination = false;
$modules = $model->getModules();
$data = $dataProvider->getData();
//override setting use user_setting
$customizable = array();
if (count($data)) {
foreach ($data as $i => $row) {
/** var CActiveRecord $row */
if ($row->customizable) {
//load data from user_setting
$custom = UserSetting::model()->findByAttributes(array('param_name' => $row->name, 'user_id' => Yii::app()->user->id));
if (is_object($custom)) {
$data[$i]->value = $custom->value;
} else {
$custom = new UserSetting();
$custom->user_id = Yii::app()->user->id;
$custom->param_name = $row->name;
}
$customizable[] = $custom;
}
}
}
$paramForm = $this->createWidget('Admin.components.ParamForm', array('params' => $data, 'config' => null));
//TODO: load module param definitions into $config
// save new values
if (Yii::app()->request->IsPostRequest) {
//save User Settings to user_setting
if (is_array($customizable) && count($customizable)) {
foreach ($customizable as $custom) {
if ($custom instanceof UserSetting && isset($_POST[$custom->param_name])) {
$custom->value = $_POST[$custom->param_name];
if (!$custom->save()) {
Yii::log(CVarDumper::dumpAsString($custom->getErrors()), CLogger::LEVEL_ERROR, 'Admin.Setting');
}
//force not save global setting
unset($_POST[$custom->param_name]);
}
}
}
$paramForm->saveParams($_POST, ParamForm::TO_SETTING_TABLE);
//update Settings Class
if ($currentWorkflow->id == $workflowId && isset($_POST['SettingParam'], $_POST['SettingParam']['module'])) {
$module = $_POST['SettingParam']['module'];
if ($module == 'module_system') {
$module = '';
}
$this->api('Xpress.Settings.db2php', array('module' => $module));
}
//update parameters to global and other workflows
foreach ($paramForm->params as $param) {
if (isset($_POST['sync_global'])) {
$this->api('Xpress.SettingParam.syncValue', array('attrs' => $param->attributes));
//update cache file global
$this->api('Xpress.Settings.db2php', array('module' => $param->module, 'path' => cachePath(true)));
}
if (isset($_POST['sync_other'])) {
//.........这里部分代码省略.........
示例8: findWorkflow
/**
* first time install CMS don't have any Settings generate
* and XServer inprogress init, CmsManager Service not init
* we must find settings of workflow by manual
*
* @return int mixed workflow
*/
protected function findWorkflow()
{
$url = parse_url(app()->request->getHostInfo(), PHP_URL_HOST);
if (!isset(self::$_workflows[$url])) {
Yii::import('Cms.models.*');
$criteria = new CDbCriteria();
$criteria->with = array('urls' => array('together' => true, 'select' => false));
$criteria->compare('urls.url', $url);
$criteria->compare('urls.status', true);
$workflow = Workflow::model()->find($criteria);
if (is_object($workflow)) {
self::$_workflows[$url] = $workflow;
} else {
self::$_workflows[$url] = false;
}
}
return self::$_workflows[$url];
}
示例9: array
echo Yii::t('workflow', 'Please summarize how this stage was completed.');
?>
</div>
<div class="row">
<?php
echo CHtml::textArea('workflowComment', '', array('style' => 'width:260px;height:80px;'));
echo CHtml::hiddenField('workflowCommentWorkflowId', '', array('id' => 'workflowCommentWorkflowId'));
echo CHtml::hiddenField('workflowCommentStageNumber', '', array('id' => 'workflowCommentStageNumber'));
?>
</div>
</form>
</div>
<!-- dialog to contain Workflow Stage Details-->
<div id="workflowStageDetails"></div>
<div class="row">
<div id="workflow-diagram">
<?php
// true = include dropdowns
$workflowStatus = Workflow::getWorkflowStatus($currentWorkflow, $model->id, X2Model::getAssociationType(get_class($model)));
//echo Workflow::renderWorkflow($workflowStatus);
if (sizeof($workflowStatus['stages']) > 1) {
$workflow = Workflow::model()->findByPk($workflowStatus['id']);
$colors = $workflow->getWorkflowStageColors(sizeof($workflowStatus['stages']));
Yii::app()->controller->renderPartial('application.modules.workflow.views.workflow._inlineFunnel', array('workflowStatus' => $workflowStatus, 'stageCount' => sizeof($workflowStatus['stages']), 'colors' => $colors));
}
?>
</div>
</div>
示例10: actionManageRoles
public function actionManageRoles()
{
$model = new Roles();
$dataProvider = new CActiveDataProvider('Roles');
$roles = $dataProvider->getData();
$arr = array();
foreach ($roles as $role) {
$arr[$role->name] = $role->name;
}
$temp = Workflow::model()->findAll();
$workflows = array();
foreach ($temp as $workflow) {
$workflows[$workflow->id] = $workflow->name;
}
$this->render('manageRoles', array('dataProvider' => $dataProvider, 'model' => $model, 'roles' => $arr, 'workflows' => $workflows));
}
示例11: actionGetStageValue
public function actionGetStageValue($id, $stage, $users, $modelType, $start, $end)
{
$dateRange = self::getDateRange();
$expectedCloseDateDateRange = self::getDateRange('expectedCloseDateStart', 'expectedCloseDateEnd', 'expectedCloseDateRange');
$workflow = Workflow::model()->findByPk($id);
if ($workflow !== null) {
$workflowStatus = Workflow::getWorkflowStatus($id);
$counts = Workflow::getStageCounts($workflowStatus, $dateRange, $expectedCloseDateDateRange, $users, $modelType);
$this->renderPartial('_dataSummary', array('stageName' => $workflow->getStageName($stage), 'count' => $counts[$stage - 1]));
}
}
示例12: actionSyncValueToOther
/**
* copy param value of workflow to default param or to others workflow
*
* @param array $attrs
*/
public function actionSyncValueToOther(array $attrs)
{
Yii::import('Cms.models.*');
//find other workflows
if (isset($attrs['workflow_id'])) {
$workflow = Workflow::model()->findByPk($attrs['workflow_id']);
if (is_object($workflow)) {
$criteria = new CDbCriteria();
$criteria->compare('id', '<>' . $workflow->id);
$criteria->addCondition('t.name NOT LIKE \'live\'', 'AND');
$criteria->compare('site_id', $workflow->site_id);
$models = Workflow::model()->findAll($criteria);
if (count($models)) {
foreach ($models as $model) {
$this->actionSyncValue($attrs, $model->id);
}
}
$this->result = $models;
}
}
}