本文整理汇总了PHP中X2Model::getModelOfTypeWithName方法的典型用法代码示例。如果您正苦于以下问题:PHP X2Model::getModelOfTypeWithName方法的具体用法?PHP X2Model::getModelOfTypeWithName怎么用?PHP X2Model::getModelOfTypeWithName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类X2Model
的用法示例。
在下文中一共展示了X2Model::getModelOfTypeWithName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validateAssociationId
/**
* if association name is sent without id, try to lookup the record by name and type
*/
public function validateAssociationId($attribute)
{
$value = $this->{$attribute};
if (is_string($this->associationName) && $this->associationName !== '') {
$associatedModel = X2Model::getModelOfTypeWithName($this->associationType, $this->associationName);
if ($associatedModel) {
$this->associationId = $associatedModel->id;
} else {
$this->addError('associationName', Yii::t('actions', 'Invalid association name'));
}
}
if (!isset($this->associationId)) {
return false;
}
}
示例2: validateParams
/**
* Helper method for action<workflow action> actions to validate get parameters and to
* retrieve the associated model.
* @param int $workflowId the id of the workflow
* @param int $stageNumber the number of the stage
* @param int $modelId the id of the associated model
* @param string $type the association type of the associated model
* @return object model with specified id and associationType
*/
private function validateParams($workflowId, $stageNumber, $modelId, $type, $recordName = null)
{
if (!is_numeric($workflowId) || !is_numeric($stageNumber) || !is_numeric($modelId) && $recordName === null) {
throw new CHttpException(400, 'Bad Request');
}
if (!is_numeric($modelId)) {
$model = X2Model::getModelOfTypeWithName($type, $recordName);
} else {
$model = X2Model::getModelOfTypeWithId($type, $modelId, true);
}
if ($model === null) {
throw new CHttpException(400, 'Bad Request');
}
return $model;
}
示例3: actionPublisherCreate
public function actionPublisherCreate()
{
if (isset($_POST['SelectedTab'], $_POST['Actions']) && (!Yii::app()->user->isGuest || Yii::app()->user->checkAccess($_POST['Actions']['associationType'] . 'View'))) {
Yii::app()->clientScript->scriptMap['*.css'] = false;
// if association name is sent without id, try to lookup the record by name and type
if (isset($_POST['calendarEventTab']) && $_POST['calendarEventTab'] && isset($_POST['Actions']['associationName']) && empty($_POST['Actions']['associationId'])) {
$associatedModel = X2Model::getModelOfTypeWithName($_POST['Actions']['associationType'], $_POST['Actions']['associationName']);
if ($associatedModel) {
$_POST['Actions']['associationId'] = $associatedModel->id;
} else {
echo CJSON::encode(array('error' => Yii::t('actions', 'Invalid association name')));
Yii::app()->end();
}
}
if (!Yii::app()->user->isGuest) {
$model = new Actions();
} else {
$model = new Actions('guestCreate');
$model->verifyCode = $_POST['Actions']['verifyCode'];
}
$model->setX2Fields($_POST['Actions']);
// format dates,
if (isset($_POST[get_class($model)]['dueDate'])) {
$model->dueDate = Formatter::parseDateTime($_POST[get_class($model)]['dueDate']);
}
if ($_POST['SelectedTab'] == 'new-event' || $_POST['SelectedTab'] == 'new-small-calendar-event') {
$model->disableBehavior('changelog');
$event = new Events();
$event->type = 'calendar_event';
$event->visibility = $model->visibility;
$event->associationType = 'Actions';
$event->timestamp = $model->dueDate;
$model->type = 'event';
if ($model->completeDate) {
$model->completeDate = Formatter::parseDateTime($model->completeDate);
} else {
$model->completeDate = $model->dueDate;
}
}
// format association
if ($model->associationId == '') {
$model->associationId = 0;
}
$association = $this->getAssociation($model->associationType, $model->associationId);
if ($association) {
$model->associationName = $association->name;
if ($association->hasAttribute('lastActivity')) {
$association->lastActivity = time();
$association->update(array('lastActivity'));
X2Flow::trigger('RecordUpdateTrigger', array('model' => $association));
}
} else {
$model->associationName = 'none';
}
if ($model->associationName == 'None' && $model->associationType != 'none') {
$model->associationName = ucfirst($model->associationType);
}
if (in_array($_POST['SelectedTab'], array('log-a-call', 'new-comment', 'log-time-spent'))) {
// Set the complete date accordingly:
if (!empty($_POST[get_class($model)]['completeDate'])) {
$model->completeDate = Formatter::parseDateTime($_POST[get_class($model)]['completeDate']);
}
foreach (array('dueDate', 'completeDate') as $attr) {
if (empty($model->{$attr})) {
$model->{$attr} = time();
}
}
if ($model->dueDate > $model->completeDate) {
// User specified a negative time range! Let's say that the
// starting time is equal to when it ended (which is earlier)
$model->dueDate = $model->completeDate;
}
$model->complete = 'Yes';
$model->visibility = '1';
$model->assignedTo = Yii::app()->user->getName();
$model->completedBy = Yii::app()->user->getName();
if ($_POST['SelectedTab'] == 'log-a-call') {
$model->type = 'call';
} elseif ($_POST['SelectedTab'] == 'log-time-spent') {
$model->type = 'time';
} else {
$model->type = 'note';
}
}
if (in_array($model->type, array('call', 'time', 'note'))) {
$event = new Events();
$event->associationType = 'Actions';
$event->type = 'record_create';
$event->user = Yii::app()->user->getName();
$event->visibility = $model->visibility;
$event->subtype = $model->type;
}
// save model
$model->createDate = time();
if (!empty($model->type)) {
$model->disableBehavior('changelog');
}
if ($model->save()) {
// action saved to database *
if (isset($_POST['Actions']['reminder']) && $_POST['Actions']['reminder']) {
//.........这里部分代码省略.........