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

  • AdminController
  • Api2Controller
  • ApiController
  • BugReportsController
  • CommonSiteControllerBehavior
  • ProfileController
  • RelationshipsController
  • SearchController
  • SiteController
  • StudioController
  • TemplatesController
  • TopicsController
  • x2base
  • X2Controller
  • 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: Yii::import('application.components.x2flow.X2FlowItem');
 38: Yii::import('application.components.x2flow.actions.*');
 39: Yii::import('application.components.x2flow.triggers.*');
 40: 
 41: /**
 42:  * @package application.controllers
 43:  */
 44: class StudioController extends x2base {
 45: 
 46:     public $modelClass = 'X2Flow';
 47: 
 48:     // public $layout = '//layouts/column1';
 49:     public function filters() {
 50:         return array(
 51:             'setPortlets',
 52:             //'accessControl',
 53:         );
 54:     }
 55: 
 56: 
 57:     public function behaviors(){
 58:         return array_merge (parent::behaviors () , 
 59:             array(
 60:                 'ImportExportBehavior' => array('class' => 'ImportExportBehavior'),
 61:             )
 62:         );
 63:     }
 64: 
 65: 
 66:     public function actions() {
 67:         if(file_exists(Yii::app()->getBasePath().'/components/FlowDesignerAction.php')) {
 68:             return array(
 69:                 'flowDesigner'=>array(
 70:                     'class'=>'FlowDesignerAction'
 71:                 ),
 72:             );
 73:         }
 74:         return array();
 75:     }
 76: 
 77: 
 78:     public function actionFlowIndex() {
 79:         $this->render('flowIndex');
 80:     }
 81: 
 82:     public function actionTriggerLogs($pageSize=null) {
 83:         $triggerLogsDataProvider = new CActiveDataProvider('TriggerLog', array(
 84:             'criteria' => array(
 85:                 'order' => 'triggeredAt DESC'
 86:             ),
 87:             'pagination'=>array(
 88:                 'pageSize' => !empty($pageSize) ?
 89:                     $pageSize :
 90:                     Profile::getResultsPerPage()
 91:             ),
 92:         ));
 93:         $viewParams['triggerLogsDataProvider'] = $triggerLogsDataProvider;
 94:         $this->render('triggerLogs', array (
 95:             'triggerLogsDataProvider' => $triggerLogsDataProvider
 96:             )
 97:         );
 98:     }
 99: 
100:     public function actionDeleteFlow($id) {
101:         $model = $this->loadModel($id);
102:         $model->delete();
103:         $this->redirect(array('flowIndex'));
104:     }
105: 
106:     public function actionGetParams($name,$type) {
107:         if($type === 'action') {
108:             $paramRules = X2FlowAction::getParamRules($name);    // X2Flow Actions
109:         } elseif($type === 'trigger') {
110:             $paramRules = X2FlowTrigger::getParamRules($name);    // X2Flow Triggers
111:         } elseif($type === 'condition') {
112:             // generic conditions (for triggers and switches)
113:             $paramRules = X2FlowTrigger::getGenericCondition($name); 
114:         } else {
115:             $paramRules = false;
116:         }
117: 
118:         if($paramRules !== false) {
119:             if($type === 'condition') {
120:                 if(isset($paramRules['options']))
121:                     $paramRules['options'] = AuxLib::dropdownForJson($paramRules['options']);
122:             } else {
123:                 // find any dropdowns and reformat them
124:                 foreach($paramRules['options'] as &$option) { 
125:                     if(isset($option['options'])) // so the item order is preserved in JSON
126:                         $option['options'] = AuxLib::dropdownForJson($option['options']);
127:                 }
128:                 // do the same for suboptions, if they're present
129:                 if (isset ($paramRules['suboptions'])) {
130:                     foreach($paramRules['suboptions'] as &$subOption) {
131:                         if(isset($subOption['options']))        
132:                             $subOption['options'] = AuxLib::dropdownForJson(
133:                                 $subOption['options']);
134:                     }
135:                 }
136:             }
137:         }
138:         echo CJSON::encode($paramRules);
139:     }
140: 
141:     // reports TODO
142:     public function actionGetFields($model) {
143:         if(!class_exists($model)) {
144:             echo 'false';
145:             return;
146:         }
147:         $fieldModels = X2Model::model($model)->getFields();
148:         $fields = array();
149: 
150:         foreach($fieldModels as &$field) {
151:             if($field->isVirtual)
152:                 continue;
153:             $data = array(
154:                 'name' => $field->fieldName,
155:                 'label' => $field->attributeLabel,
156:                 'type' => $field->type,
157:             );
158: 
159:             if($field->required)
160:                 $data['required'] = 1;
161:             if($field->readOnly)
162:                 $data['readOnly'] = 1;
163:             if($field->type === 'assignment' || $field->type === 'optionalAssignment' ) {
164:                 $data['options'] = AuxLib::dropdownForJson(
165:                     X2Model::getAssignmentOptions(true, true));
166:                 if ($field->type === 'assignment')
167:                     $data['multiple'] = $field->linkType === 'multiple' ? 1 : 0;
168:             } elseif($field->type === 'dropdown') {
169:                 $data['linkType'] = $field->linkType;
170:                 $dropdown = Dropdowns::model ()->findByPk ($field->linkType);
171:                 if (!$dropdown) continue;
172:                 $data['options'] = AuxLib::dropdownForJson(Dropdowns::getItems($field->linkType));
173:                 $data['multiple'] = $dropdown->multi ? 1 : 0;
174:             }
175: 
176:             if($field->type === 'link') {
177:                 $staticLinkModel = X2Model::model($field->linkType);
178:                 if(array_key_exists('X2LinkableBehavior', $staticLinkModel->behaviors())) {
179:                     $data['linkType'] = $field->linkType;
180:                     $data['linkSource'] = Yii::app()->controller->createUrl(
181:                         $staticLinkModel->autoCompleteSource);
182:                 }
183:             }
184: 
185: 
186:             $fields[] = $data;
187:         }
188:         usort ($fields, function ($a, $b) {
189:             return strcmp ($a['label'], $b['label']);
190:         });
191:         echo CJSON::encode($fields);
192:     }
193: 
194:     public function actionDeleteAllTriggerLogs ($flowId) {
195:         if (isset ($flowId)) {
196:             $triggerLogs = TriggerLog::model()->findAllByAttributes (array (
197:                 'flowId' => $flowId
198:             ));
199:             foreach ($triggerLogs as $log) {
200:                 $log->delete ();
201:             }
202:             echo "success";
203:         } else {
204:             echo "failure";
205:         }
206:     }
207: 
208:     public function actionDeleteAllTriggerLogsForAllFlows () {
209:         $triggerLogs = TriggerLog::model()->findAll ();
210:         foreach ($triggerLogs as $log) {
211:             $log->delete ();
212:         }
213:         echo "success";
214:     }
215: 
216:     public function actionDeleteTriggerLog ($id) {
217:         if (isset ($id)) {
218:             $triggerLog = TriggerLog::model()->findByAttributes (array (
219:                 'id' => $id
220:             ));
221:             if (!empty ($triggerLog)) {
222:                 $triggerLog->delete ();
223:                 echo "success";
224:                 return;
225:             }
226:         }
227:         echo "failure";
228:     }
229:     
230:     
231: 
232:      
233: 
234: }
235: 
X2CRM Documentation API documentation generated by ApiGen 2.8.0