Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • None
  • system
    • base
    • caching
    • console
    • db
      • ar
      • schema
    • validators
    • web
      • actions
      • auth
      • helpers
      • widgets
        • captcha
        • pagers
  • zii
    • widgets
      • grid

Classes

  • ActionCompleteTrigger
  • ActionOverdueTrigger
  • ActionUncompleteTrigger
  • BaseUserTrigger
  • BaseWorkflowStageTrigger
  • BaseWorkflowTrigger
  • BaseX2FlowEmail
  • BaseX2FlowWorkflowStageAction
  • CampaignEmailClickTrigger
  • CampaignEmailOpenTrigger
  • CampaignUnsubscribeTrigger
  • EmailOpenTrigger
  • InboundEmailTrigger
  • MacroTrigger
  • OutboundEmailTrigger
  • RecordCreateTrigger
  • RecordDeleteTrigger
  • RecordUpdateTrigger
  • RecordViewTrigger
  • UserLoginTrigger
  • UserLogoutTrigger
  • WorkflowCompleteStageTrigger
  • WorkflowCompleteTrigger
  • WorkflowRevertStageTrigger
  • WorkflowStartStageTrigger
  • WorkflowStartTrigger
  • X2FlowApiCall
  • X2FlowCreateAction
  • X2FlowCreateEvent
  • X2FlowCreateNotif
  • X2FlowEmail
  • X2FlowRecordComment
  • X2FlowRecordCreate
  • X2FlowRecordCreateAction
  • X2FlowRecordDelete
  • X2FlowRecordListAdd
  • X2FlowRecordListRemove
  • X2FlowRecordReassign
  • X2FlowRecordTag
  • X2FlowRecordUpdate
  • X2FlowSplitter
  • X2FlowSwitch
  • X2FlowWorkflowCompleteStage
  • X2FlowWorkflowRevertStage
  • X2FlowWorkflowStartStage
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /*****************************************************************************************
  3:  * X2Engine Open Source Edition is a customer relationship management program developed by
  4:  * X2Engine, Inc. Copyright (C) 2011-2016 X2Engine Inc.
  5:  * 
  6:  * This program is free software; you can redistribute it and/or modify it under
  7:  * the terms of the GNU Affero General Public License version 3 as published by the
  8:  * Free Software Foundation with the addition of the following permission added
  9:  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 10:  * IN WHICH THE COPYRIGHT IS OWNED BY X2ENGINE, X2ENGINE DISCLAIMS THE WARRANTY
 11:  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 12:  * 
 13:  * This program is distributed in the hope that it will be useful, but WITHOUT
 14:  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 15:  * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
 16:  * details.
 17:  * 
 18:  * You should have received a copy of the GNU Affero General Public License along with
 19:  * this program; if not, see http://www.gnu.org/licenses or write to the Free
 20:  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 21:  * 02110-1301 USA.
 22:  * 
 23:  * You can contact X2Engine, Inc. P.O. Box 66752, Scotts Valley,
 24:  * California 95067, USA. or at email address contact@x2engine.com.
 25:  * 
 26:  * The interactive user interfaces in modified source and object code versions
 27:  * of this program must display Appropriate Legal Notices, as required under
 28:  * Section 5 of the GNU Affero General Public License version 3.
 29:  * 
 30:  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
 31:  * these Appropriate Legal Notices must retain the display of the "Powered by
 32:  * X2Engine" logo. If the display of the logo is not reasonably feasible for
 33:  * technical reasons, the Appropriate Legal Notices must display the words
 34:  * "Powered by X2Engine".
 35:  *****************************************************************************************/
 36: 
 37: /**
 38:  * X2FlowAction that creates a new record
 39:  *
 40:  * @package application.components.x2flow.actions
 41:  */
 42: class X2FlowRecordCreate extends X2FlowAction {
 43:     public $title = 'Create Record';
 44:     public $info = '';
 45: 
 46:     public function paramRules() {
 47:         return array_merge (parent::paramRules (), array (
 48:             'title' => $this->title,
 49:             'modelClass' => 'modelClass',
 50:             'options' => array(
 51:                 array('name'=>'attributes'),
 52:                 array(
 53:                     'name'=>'modelClass','label'=>Yii::t('studio','Record Type'),
 54:                     'type'=>'dropdown',
 55:                     'options'=>X2Flow::getModelTypes(true)
 56:                 ),
 57:                 array(
 58:                     'name'=>'createRelationship',
 59:                     'label' => 
 60:                         Yii::t('studio', 'Create Relationship'). 
 61:                         '&nbsp;'.
 62:                         X2Html::hint2 (
 63:                             Yii::t('app', 'Check this box if you want a new relationship to be '.
 64:                                 'established between the record created by this action and the '.
 65:                                 'record that triggered the flow.')), 
 66:                     'type'=>'boolean',
 67:                     'defaultVal' => false,
 68:                 ),
 69:             ),
 70:             /*'suboptions' => array (
 71:                 array (
 72:                     'name' => 'dependency',
 73:                     'dependentOn' => 'createRelationship',
 74:                 ),
 75:                 array(
 76:                     'name'=>'relatedModelClass',
 77:                     'label'=>Yii::t('studio','Related Record Type'),
 78:                     'type'=>'dropdown',
 79:                     'optional' => true,
 80:                     'defaultVal' => 'Accounts',
 81:                     'options'=>X2Model::getModelTypesWhichSupportRelationships (true),
 82:                 ),
 83:                 array(
 84:                     'name'=>'relatedModelName',
 85:                     'label'=>Yii::t('studio', 'Related Record Name'),
 86:                     'type'=>'dependentAutocomplete',
 87:                     'linkSource'=>Yii::app()->createUrl(
 88:                         CActiveRecord::model('Accounts')->autoCompleteSource),
 89:                     'getAutoCompleteUrl'=>Yii::app()->createUrl(
 90:                         '/studio/studio/ajaxGetModelAutocomplete', 
 91:                         array ('modelType' => 'Accounts')
 92:                     ),  
 93:                     'dependency' => 'relatedModelClass',
 94:                     'optional'=>1,
 95:                 ),
 96:             ),*/
 97:         ));
 98:     }
 99: 
100:     public function execute(&$params) {
101:         // make sure this is a valid model type
102:         if(!is_subclass_of($this->config['modelClass'],'X2Model'))  
103:             return array (false, "");
104:         if(!isset($this->config['attributes']) || empty($this->config['attributes']))
105:             return array (false, "");
106: 
107:         // verify that if create relationship option was set, that a relationship can be made
108:         if($this->parseOption('createRelationship', $params)) {
109:             $acceptedModelTypes = X2Model::getModelTypesWhichSupportRelationships ();
110: 
111:             if (!in_array ($this->config['modelClass'], $acceptedModelTypes)) {
112:                 return array (false, Yii::t('admin', 'Relationships cannot be made with records '.
113:                     'of type {type}.', array ('{type}' => $this->config['modelClass'])));
114:             }
115:             if (!isset ($params['model'])) { // no model passed to trigger
116:                 return array (false, '');
117:             }
118:             if (!in_array (get_class ($params['model']), $acceptedModelTypes)) {
119:                 return array (false, Yii::t('admin', 'Relationships cannot be made with records '.
120:                     'of type {type}.', array ('{type}' => get_class ($params['model']))));
121:             }
122:         }
123: 
124:         $model = new $this->config['modelClass'];
125:         $model->setScenario ('X2FlowCreateAction');
126:         if ($this->setModelAttributes($model,$this->config['attributes'],$params) && 
127:             $model->save()) {
128: 
129:             if($this->parseOption('createRelationship', $params)) {
130:                 $params['model']->createRelationship($model);
131:             }
132: 
133:             return array (
134:                 true,
135:                 Yii::t('studio', 'View created record: ').$model->getLink ());
136:         } else {
137:             $errors = $model->getErrors ();
138:             return array(false, array_shift($errors));
139:         }
140:     }
141: }
142: 
X2CRM Documentation API documentation generated by ApiGen 2.8.0