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: class BugReportsController extends x2base {
 38:     public $modelClass = 'BugReports';
 39: 
 40:     public function behaviors () {
 41:          return array_merge (parent::behaviors (), array (
 42:             'X2MobileControllerBehavior' => array(
 43:                 'class' => 
 44:                     'application.modules.mobile.components.behaviors.X2MobileControllerBehavior'
 45:             ),
 46:          ));
 47:     }
 48: 
 49:     /**
 50:      * @var string the default layout for the views. Defaults to '//layouts/column2', meaning
 51:      * using two-column layout. See 'protected/views/layouts/column2.php'.
 52:      */
 53:     public function actionGetItems($term){
 54:         X2LinkableBehavior::getItems ($term);
 55:     }
 56: 
 57:     /**
 58:      * Displays a particular model.
 59:      * @param integer $id the ID of the model to be displayed
 60:      */
 61:     public function actionView($id) {
 62:         User::addRecentItem ('BugReports', $id);
 63:         $type='BugReports';
 64:         $model=$this->loadModel($id);
 65:         if($this->checkPermissions($model,'view')) {
 66:             parent::view($model, $type);
 67:         }else{
 68:             $this->redirect('index');
 69:         }
 70:     }
 71: 
 72:     /**
 73:      * Creates a new model.
 74:      * If creation is successful, the browser will be redirected to the 'view' page.
 75:      */
 76:     public function actionCreate() {
 77:         $model=new BugReports;
 78:         $users=User::getNames();
 79: 
 80:         if(isset($_POST['BugReports'])) {
 81:             $temp = $model->attributes;
 82:             $model->setX2Fields($_POST['BugReports']);
 83:             parent::create($model, $temp, 0);
 84:         }
 85: 
 86:         $this->render('create',array(
 87:             'model'=>$model,
 88:             'users'=>$users,
 89:         ));
 90: 
 91:     }
 92: 
 93:     /**
 94:      * Updates a particular model.
 95:      * If update is successful, the browser will be redirected to the 'view' page.
 96:      * @param integer $id the ID of the model to be updated
 97:      */
 98:     public function actionUpdate($id) {
 99:         $model = $this->loadModel($id);
100:         $users = User::getNames();
101: 
102:         if(isset($_POST['BugReports'])) {
103:             $temp = $model->attributes;
104:             $model->setX2Fields($_POST['BugReports']);
105:             parent::update($model,$temp,'0');
106:         }
107: 
108:         $this->render('update',array(
109:             'model'=>$model,
110:             'users'=>$users,
111:         ));
112:     }
113:     /**
114:      * Deletes a particular model.
115:      * If deletion is successful, the browser will be redirected to the 'admin' page.
116:      * @param integer $id the ID of the model to be deleted
117:      */
118:     public function actionDelete($id)
119:     {
120:         if(Yii::app()->request->isPostRequest)
121:         {
122:             // we only allow deletion via POST request
123:             $model=$this->loadModel($id);
124:             $this->cleanUpTags($model);
125:             $model->delete();
126: 
127:             // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
128:             if(!isset($_GET['ajax']))
129:                 $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('index'));
130:         }
131:         else
132:             throw new CHttpException(400,'Invalid request. Please do not repeat this request again.');
133:     }
134: 
135:     /**
136:      * Lists all models.
137:      */
138:     public function actionIndex() {
139:         $model=new BugReports('search');
140:         $this->render('index', array('model'=>$model));
141:     }
142: 
143:     /**
144:      * Manages all models.
145:      */
146:     public function actionAdmin() {
147:         $model=new BugReports('search');
148:         $this->render('admin', array('model'=>$model));
149:     }
150: 
151:     /**
152:      * Returns the data model based on the primary key given in the GET variable.
153:      * If the data model is not found, an HTTP exception will be raised.
154:      * @param integer the ID of the model to be loaded
155:      */
156:     public function loadModel($id)
157:     {
158:         $model=BugReports::model()->findByPk((int)$id);
159:         if($model===null)
160:             throw new CHttpException(404,'The requested page does not exist.');
161:         return $model;
162:     }
163: 
164:     /**
165:      * Performs the AJAX validation.
166:      * @param CModel the model to be validated
167:      */
168:     protected function performAjaxValidation($model)
169:     {
170:         if(isset($_POST['ajax']) && $_POST['ajax']==='bugReports-form')
171:         {
172:             echo CActiveForm::validate($model);
173:             Yii::app()->end();
174:         }
175:     }
176: 
177:     /**
178:      *  Show or hide a certain status in the gridview
179:      *
180:      *  Called through ajax with a status and if that status should be shown or hidden.
181:      *  Saves the result in the user's profile.
182:      *
183:      */
184:     public function actionStatusFilter() {
185: 
186:         if(isset($_POST['all'])) {    // show all the things!!
187:             Yii::app()->params->profile->hideBugsWithStatus = CJSON::encode(array());    // hide none
188:             Yii::app()->params->profile->update(array('hideBugsWithStatus'));
189: 
190:         } elseif(isset($_POST['none'])) {    // hide all the things!!!!11
191:             $statuses = array();
192: 
193:             $dropdownId = Yii::app()->db->createCommand()    // get the ID of the statuses dropdown via fields table
194:                 ->select('linkType')
195:                 ->from('x2_fields')
196:                 ->where('modelName="BugReports" AND fieldName="status" AND type="dropdown"')
197:                 ->queryScalar();
198:             if($dropdownId !== null)
199:                 $statuses = Dropdowns::getItems($dropdownId);    // get the actual statuses
200: 
201:             Yii::app()->params->profile->hideBugsWithStatus = CJSON::encode($statuses);
202:             Yii::app()->params->profile->update(array('hideBugsWithStatus'));
203: 
204:         } elseif(isset($_POST['checked'])) {
205: 
206:             $checked = CJSON::decode($_POST['checked']);
207:             $status = isset($_POST['status'])? $_POST['status'] : false;
208: 
209:             // var_dump($checked);
210:             // var_dump($status);
211: 
212:             $hideStatuses = CJSON::decode(Yii::app()->params->profile->hideBugsWithStatus); // get a list of statuses the user wants to hide
213:             if($hideStatuses === null || !is_array($hideStatuses))
214:                 $hideStatuses = array();
215: 
216:             // var_dump($checked);
217:             // var_dump(in_array($status, $hideStatuses));
218:             if($checked && ($key = array_search($status, $hideStatuses)) !== false) { // if we want to show the status, and it's not being shown
219:                 unset($hideStatuses[$key]); // show status
220:             } else if(!$checked && !in_array($status, $hideStatuses)) { // if we want to hide the status, and it's not being hidden
221:                 $hideStatuses[] = $status;
222:             }
223: 
224:             Yii::app()->params->profile->hideBugsWithStatus = CJSON::encode($hideStatuses);
225:             Yii::app()->params->profile->update(array('hideBugsWithStatus'));
226:         }
227:     }
228: }
229: 
X2CRM Documentation API documentation generated by ApiGen 2.8.0