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

  • FileSystemObject
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: 
  3: /*****************************************************************************************
  4:  * X2Engine Open Source Edition is a customer relationship management program developed by
  5:  * X2Engine, Inc. Copyright (C) 2011-2016 X2Engine Inc.
  6:  * 
  7:  * This program is free software; you can redistribute it and/or modify it under
  8:  * the terms of the GNU Affero General Public License version 3 as published by the
  9:  * Free Software Foundation with the addition of the following permission added
 10:  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 11:  * IN WHICH THE COPYRIGHT IS OWNED BY X2ENGINE, X2ENGINE DISCLAIMS THE WARRANTY
 12:  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 13:  * 
 14:  * This program is distributed in the hope that it will be useful, but WITHOUT
 15:  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 16:  * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
 17:  * details.
 18:  * 
 19:  * You should have received a copy of the GNU Affero General Public License along with
 20:  * this program; if not, see http://www.gnu.org/licenses or write to the Free
 21:  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 22:  * 02110-1301 USA.
 23:  * 
 24:  * You can contact X2Engine, Inc. P.O. Box 66752, Scotts Valley,
 25:  * California 95067, USA. or at email address contact@x2engine.com.
 26:  * 
 27:  * The interactive user interfaces in modified source and object code versions
 28:  * of this program must display Appropriate Legal Notices, as required under
 29:  * Section 5 of the GNU Affero General Public License version 3.
 30:  * 
 31:  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
 32:  * these Appropriate Legal Notices must retain the display of the "Powered by
 33:  * X2Engine" logo. If the display of the logo is not reasonably feasible for
 34:  * technical reasons, the Appropriate Legal Notices must display the words
 35:  * "Powered by X2Engine".
 36:  *****************************************************************************************/
 37: 
 38: /**
 39:  * Description of FileSystemObject
 40:  *
 41:  * @package application.modules.docs.components
 42:  */
 43: class FileSystemObject {
 44: 
 45:     public $id;
 46:     public $parentId;
 47:     public $type;
 48:     public $objId;
 49:     public $name;
 50:     public $createdBy;
 51:     public $lastUpdated;
 52:     public $updatedBy;
 53:     public $visibility;
 54:     public $title;
 55:     public $isParent = false;
 56:     
 57:     public static function getListViewHeader(){
 58:         $linkHeader = X2Html::tag(
 59:             'div', array('class' => 'file-system-object-link',), Yii::t('docs','Name'));
 60:         $attrHeaderContent = X2Html::tag(
 61:             'span', array('class' => 'file-system-object-owner'), Yii::t('docs', 'Owner'))
 62:             . X2Html::tag(
 63:                 'span', 
 64:                 array('class' => 'file-system-object-last-updated'), Yii::t('docs', 'Last Updated'))
 65:             . X2Html::tag(
 66:                 'span', 
 67:                 array('class' => 'file-system-object-visibility'), Yii::t('docs', 'Visibility'));
 68:         $attrHeader = X2Html::tag(
 69:             'div', array('class' => 'file-system-object-attributes'), $attrHeaderContent);
 70:         $headerContent = X2Html::tag(
 71:             'div', array('class' => 'file-system-clear-fix'), $linkHeader . $attrHeader);
 72:         return X2Html::tag('div', array('class' => 'file-system-header page-title'), $headerContent);
 73:     }
 74: 
 75:     public function __construct($options) {
 76:         foreach ($options as $key => $value) {
 77:             if (property_exists(get_class(), $key)) {
 78:                 $this->$key = $value;
 79:             }
 80:         }
 81:     }
 82: 
 83:     public function getIcon() {
 84:         return X2Html::fa($this->type === 'folder' ? 'folder-open' : 'file-text');
 85:     }
 86: 
 87:     public function getLink() {
 88:         if ($this->type === 'folder') {
 89:             return X2Html::link($this->name, '#', array(
 90:                 'class'=>'folder-link pseudo-link',
 91:                 'data-id'=>$this->objId,
 92:             ));
 93:         } else {
 94:             return X2Html::link(
 95:                 $this->name, 
 96:                 Yii::app()->controller->createUrl('/docs/view', array('id' => $this->objId)));
 97:         }
 98:     }
 99: 
100:     public function renderName () {
101:         $options = array (
102:             "class" => "file-system-object-name",
103:         );
104: 
105:         if ($this->title && preg_match ('/^[a-zA-Z0-9 \-]+$/', $this->title)) 
106:             $options['title'] = $this->title;
107:         return $this->getIcon ().CHtml::tag ("span", $options, $this->getLink ());
108:     }
109:     
110:     public function getOwner(){
111:         if(!empty($this->createdBy)){
112:             $user = User::getUserLinks($this->createdBy, false, true);
113:             if(!empty($user)){
114:                 return $user;
115:             }
116:         }
117:         return '&nbsp;';
118:     }
119:     
120:     public function getVisibility(){
121:         if(is_null($this->visibility)){
122:             $this->visibility = 1;
123:         }
124:         $visibilities = X2PermissionsBehavior::getVisibilityOptions ();
125:         return $visibilities[$this->visibility];
126:     }
127:     
128:     public function getLastUpdateInfo(){
129:         if(!empty($this->updatedBy) && !empty($this->lastUpdated)){
130:             return Formatter::formatDateTime($this->lastUpdated);
131:         }
132:         return '&nbsp;';
133:     }
134:     
135:     public function validDroppable() {
136:         return $this->type === 'folder' && 
137:             (is_null($this->objId) || $this->objId > 0 || $this->parentId > 0) && 
138:             ($this->name != '..' || is_null($this->parentId) || $this->parentId > 0);
139:     }
140: 
141:     public function validDraggable() {
142:         return $this->name !== '..' && $this->objId > 0;
143:     }
144: 
145: }
146: 
X2CRM Documentation API documentation generated by ApiGen 2.8.0