My Console Application Class Reference

FolderController

Package application.controllers.FolderController
Inheritance class FolderController » Controller » SBaseController » CController » CBaseController » CComponent
Views createRole, findAllFiles, list, permission, roleAccess, selectRole, show, ssearch, userRole, userRole2
Source Code app/controllers/FolderController.php
FolderController defines folder actions, communicates between models and views.

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
action CAction the action currently being executed, null if no active action. CController
back Controller
cachingStack CStack stack of COutputCache objects CController
clips CMap Returns the list of clips. CController
defaultAction string specifies the default action to be 'list'. FolderController
id string ID of the controller CController
layout string the default layout for the controller view. Controller
module CWebModule the module that this controller belongs to. CController
pageTitle string the page title. CController
roleModels Get roles models by entity(file) id and entity(file) type. FolderController
rolesList Get roles array by entity(file) id and entity(file) type. FolderController
roots Controller
route string the route (module ID, controller ID and action ID) of the current request. CController
selectedTA Controller
tree Controller
uniqueId string the controller ID that is prefixed with the module ID (if any). CController
viewPath string Returns the directory containing view files for this controller. CController

Public Methods

Hide inherited methods

MethodDescriptionDefined By
__call() Calls the named method which is not a class method. CComponent
__construct() CController
__get() Returns a property value, an event handler list or a behavior based on its name. CComponent
__isset() Checks if a property value is null. CComponent
__set() Sets value of a component property. CComponent
__unset() Sets a component property to be null. CComponent
accessRules() Specifies the access control rules. FolderController
actionAdmin() Manages all folder models. FolderController
actionCreate() Creates a new model. (old version) FolderController
actionCreateRole() create folder role (old version) FolderController
actionDelete() Deletes a particular folder model. (old version) FolderController
actionDeleteRole() Delete folder role FolderController
actionEditRole() Edit folder role (old version) FolderController
actionFindAllFiles() Search all files in folder FolderController
actionList() Lists all folder models according to user permission. FolderController
actionPermission() permission setting entry page FolderController
actionRoleAccess() assign read-1, write-2, admin-3 premission to folder role FolderController
actionSearch() Search in folder. FolderController
actionSelectRole() Edits selected role or create new role FolderController
actionShow() Shows a particular folder model. FolderController
actionShowimagetbn() Shows image thumbnail 200*200 FolderController
actionShowvideotbn() Shows video thumbnail from first frame of video FolderController
actionUpdate() Updates a particular folder model. (old version) FolderController
actionUserRole() Assign user to folder role (old version) FolderController
actionUserRole2() Show folder role and user. Assign folder role to existing folder user FolderController
actionUserRoleAdd() Add new user--folder role relationship FolderController
actions() Returns a list of external action classes. CController
asa() Returns the named behavior object. CComponent
attachBehavior() Attaches a behavior to this component. CComponent
attachBehaviors() Attaches a list of behaviors to the component. CComponent
attachEventHandler() Attaches an event handler to an event. CComponent
beginCache() Begins fragment caching. CBaseController
beginClip() Begins recording a clip. CBaseController
beginContent() Begins the rendering of content that is to be decorated by the specified view. CBaseController
beginWidget() Creates a widget and executes it. CBaseController
behaviors() Returns a list of behaviors that this controller should behave as. CController
canGetProperty() Determines whether a property can be read. CComponent
canSetProperty() Determines whether a property can be set. CComponent
clearPageStates() Removes all page states. CController
createAbsoluteUrl() Creates an absolute URL for the specified action defined in this controller. CController
createAction() Creates the action instance based on the action name. CController
createUrl() Creates a relative URL for the specified action defined in this controller. CController
createWidget() Creates a widget and initializes it. CBaseController
detachBehavior() Detaches a behavior from the component. CComponent
detachBehaviors() Detaches all behaviors from the component. CComponent
detachEventHandler() Detaches an existing event handler. CComponent
disableBehavior() Disables an attached behavior. CComponent
disableBehaviors() Disables all behaviors attached to this component. CComponent
enableBehavior() Enables an attached behavior. CComponent
enableBehaviors() Enables all behaviors attached to this component. CComponent
endCache() Ends fragment caching. CBaseController
endClip() Ends recording a clip. CBaseController
endContent() Ends the rendering of content. CBaseController
endWidget() Ends the execution of the named widget. CBaseController
evaluateExpression() Evaluates a PHP expression or callback under the context of this component. CComponent
filterAccessControl() The filter method for 'accessControl' filter. CController
filterAjaxOnly() The filter method for 'ajaxOnly' filter. CController
filterPostOnly() The filter method for 'postOnly' filter. CController
filters() FolderController
forward() Processes the request using another controller action. CController
getAction() Returns the action currently being executed, null if no active action. CController
getCachingStack() Returns stack of COutputCache objects CController
getClips() Returns the list of clips. CController
getEventHandlers() Returns the list of attached event handlers for an event. CComponent
getId() Returns ID of the controller CController
getLayoutFile() Looks for the layout view script based on the layout name. CController
getModule() Returns the module that this controller belongs to. It returns null if the controller does not belong to any module CController
getPageState() Returns a persistent page state value. CController
getPageTitle() Returns the page title. Defaults to the controller name and the action name. CController
getRoleModels() Get roles models by entity(file) id and entity(file) type. FolderController
getRolesList() Get roles array by entity(file) id and entity(file) type. FolderController
getRoute() Returns the route (module ID, controller ID and action ID) of the current request. CController
getUniqueId() Returns the controller ID that is prefixed with the module ID (if any). CController
getViewFile() Looks for the view file according to the given view name. CController
getViewPath() Returns the directory containing view files for this controller. CController
hasAccess() FolderController
hasEvent() Determines whether an event is defined. CComponent
hasEventHandler() Checks whether the named event has attached handlers. CComponent
hasPrjAdmin() Check if user has folder admin permission FolderController
hasProperty() Determines whether a property is defined. CComponent
init() Initializes the controller. CController
isCachingStackEmpty() CController
loadentity() Returns the data model based on the primary key given in the GET variable. FolderController
loadfilefolders() Get file, subfolder, file&subfolder models according to folder id FolderController
loadfilefoldersWP() same as loadfilefolders but with permission checking FolderController
missingAction() Handles the request whose action is not recognized. CController
paginate() Generates pagination information. CController
processDynamicOutput() Postprocesses the dynamic output. CController
processOutput() Postprocesses the output generated by render(). CController
raiseEvent() Raises an event. CComponent
recordCachingAction() Records a method call when an output cache is in effect. CController
redirect() Redirects the browser to the specified URL or route (controller/action). CController
refresh() Refreshes the current page. CController
render() Renders a view with a layout. CController
renderDynamic() Renders dynamic content returned by the specified callback. CController
renderDynamicInternal() This method is internally used. CController
renderFile() Renders a view file. CBaseController
renderInternal() Renders a view file. CBaseController
renderPartial() Renders a view. CController
renderPartialWithHisOwnClientScript() Controller
renderText() Renders a static text string. CController
resolveViewFile() Finds a view file based on its name. CController
run() Runs the named action. CController
runAction() Runs the action after passing through all filters. CController
runActionWithFilters() Runs an action with the specified filters. CController
setAction() Sets the action currently being executed. CController
setPageState() Saves a persistent page state value. CController
setPageTitle() Sets the page title. CController
widget() Creates a widget and executes it. CBaseController

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
afterAction() This method is invoked right after an action is executed. CController
allowedAccess() The auth items that access is always allowed. Configured in srbac module's SBaseController
beforeAction() Checks if srbac access is granted for the current user SBaseController
createActionFromMap() Creates the action instance based on the action map. CController
loadPageStates() Loads page states from a hidden input. CController
onUnauthorizedAccess() SBaseController
processAdminCommand() Executes any command triggered on the admin page. FolderController
replaceDynamicOutput() Replaces the dynamic content placeholders with actual content. CController
savePageStates() Saves page states as a base64 string. CController

Events

Hide inherited events

EventDescriptionDefined By
onUnauthorizedAccess SBaseController

Property Details

defaultAction property
public string $defaultAction;

specifies the default action to be 'list'.

roleModels property read-only
public void getRoleModels()

Get roles models by entity(file) id and entity(file) type.

rolesList property read-only
public void getRolesList()

Get roles array by entity(file) id and entity(file) type.

Method Details

accessRules() method
public array accessRules()
{return} array access control rules
Source Code: app/controllers/FolderController.php#35 (show)
public function accessRules()
{
    
    
$user Yii::app()->user;
    
$isPublicAccess $this->hasAccess($user"public");
    if(!
$isPublicAccess){            
        if(
$user==null||$user->id==null)$this->redirect(array('site/login'));    
    }
    
$hasPrjAdmin $this->hasAccess($userroleAccess::ADMIN);
    
$hasPrjWrite $this->hasAccess($userroleAccess::WRITE);
    
$hasPrjRead $this->hasAccess($userroleAccess::READ);
    
    return array(
        array(
'deny',  //allow admin role actions only for system admin and project admin
            
'actions'=>array('admin','delete','createRole''roleAccess','userRole','userRole2''userRoleAdd''deleteRole''editRole''selectRole''permission'),
        
//check user has system admin or project admin access
            
'expression'=>'!Yii::app()->user->checkAccess("UserAdmin") && !'.($hasPrjAdmin),
        
        ),
        array(
'deny',  //allow write role actions only for system admin and project admin, write
            
'actions'=>array('update',),
        
//check user has system admin or project admin access
            
'expression'=>'!Yii::app()->user->checkAccess("UserAdmin") && !'.($hasPrjWrite).' && !'.($hasPrjAdmin),
        
        ),
        array(
'deny',  //allow read role actions only for system admin and project admin, write, read, publicaccess
            
'actions'=>array('search','show''showimagetbn''showimagevideotbn'),
        
//check user has system admin or project admin access
            
'expression'=>'!Yii::app()->user->checkAccess("UserAdmin") && !'.($hasPrjRead).' && !'.($hasPrjWrite).' && !'.($hasPrjAdmin).' && !'.($isPublicAccess),
        
        )

    );
}

Specifies the access control rules. This method is used by the 'accessControl' filter.

actionAdmin() method
public void actionAdmin()
Source Code: app/controllers/FolderController.php#996 (show)
public function actionAdmin()
{
    
$this->processAdminCommand();

    
$criteria=new CDbCriteria;
    
$condition='typeId='.entityType::FOLDER_TYPE;
    
$criteria->condition $condition;
    
$pages=new CPagination(entity::model()->count($criteria));
    
$pages->pageSize=self::PAGE_SIZE;
    
$pages->applyLimit($criteria);

    
$sort=new CSort('entity');
    
$sort->applyOrder($criteria);

    
$models=entity::model()->findAll($criteria);

    
$this->render('admin',array(
        
'models'=>$models,
        
'pages'=>$pages,
        
'sort'=>$sort,
    ));
}

Manages all folder models.

actionCreate() method
public void actionCreate()
Source Code: app/controllers/FolderController.php#166 (show)
public function actionCreate()
{
    
$model=new entity;
    if(isset(
$_POST['entity']))
    {
        
$model->attributes=$_POST['entity'];
        if(
$model->save())
            
$this->redirect(array('show','id'=>$model->id));
    }
    
$this->render('create',array('model'=>$model));
}

Creates a new model. (old version) If creation is successful, the browser will be redirected to the 'show' page.

actionCreateRole() method
public void actionCreateRole()
Source Code: app/controllers/FolderController.php#292 (show)
public function actionCreateRole()
{
    
$role=new role;
    
    if(isset(
$_POST['role']))
    {
        
$folderId Yii::app()->getGlobalState('currentFolder');
        
$folder entity::model()->findbyPk($folderId);
        
$role->attributes=$_POST['role'];    
        
$criteria=new CDbCriteria;
        
$condition='t.name="'.$role->name.'" and t.entityId='.$folderId;
        
$criteria->condition $condition;
    
        
$models role::model()->findAll($criteria);
        
        if(
count($models)==0){
            
            
$role->entityType entityType::FOLDER_TYPE;
            
$role->entityId $folderId;
            
$role->save();
            
            
            
//create role for subfolder, files etc
            
$this->createSubRole($folder$role);
            
            
$selectedRole $role->id;
            
$roles $this->getRolesList();
        }
    }else{
        
$roles $this->getRolesList();
        
$i=0;
        foreach(
$roles as $id=>$name):
            
$selectedRole=$id;
            
//$typemodel = cvListType::model()->findbyPk($selectedType);
            
$i++;
            if(
$i>0)break;
        endforeach;
    }
    
$model $this->loadentity($_GET['folderId']);
    
$this->render('createRole',array('role'=>$role,'roles'=>$roles'selectedRole'=>$selectedRole'model'=>$model'folder'=>$folder));
}

create folder role (old version)

actionDelete() method
public void actionDelete()
Source Code: app/controllers/FolderController.php#863 (show)
public function actionDelete()
{
    if(
Yii::app()->request->isPostRequest)
    {
        
// we only allow deletion via POST request
        
$this->loadentity()->delete();
        
$this->redirect(array('list'));
    }
    else
        throw new 
CHttpException(400,'Invalid request. Please do not repeat this request again.');
}

Deletes a particular folder model. (old version) If deletion is successful, the browser will be redirected to the 'list' page.

actionDeleteRole() method
public void actionDeleteRole()
Source Code: app/controllers/FolderController.php#402 (show)
public function actionDeleteRole()
{
    if(
Yii::app()->request->isPostRequest&&isset($_POST['command'], $_POST['id']) && $_POST['command']==='delete')
    {
        
// we only allow deletion via POST request
        
$id $_POST['id'];
        
$role=role::model()->findbyPk($id);
        
//delete userRole and roleAccess            
        
$roleAccesses $role->roleAccess;
        foreach(
$roleAccesses as $roleAcc){
            
$roleAcc->delete();
        }
        
$userRoles $role->userRole;
        foreach(
$userRoles as $userRole){
            
$userRole->delete();
        }
        
$prjModel entity::model()->findbyPk($role->entityId);
        
$this->deleteSubRole($prjModel$role->name);
        
//delete role
        
$role->delete();
        
        
$roles $this->getRolesList();
        
$i=0;
        foreach(
$roles as $id=>$name):
            
$selectedRole=$id;
            
$role role::model()->findbyPk($selectedRole);
            
$i++;
            if(
$i>0)break;
        endforeach;
        
$model $this->loadentity($_GET['folderId']);
        
$this->render('selectRole',array('role'=>$role,'roles'=>$roles'selectedRole'=>$selectedRole'model'=>$model));
    }
    else
        throw new 
CHttpException(400,'Invalid request. Please do not repeat this request again.');
}

Delete folder role

actionEditRole() method
public void actionEditRole()
Source Code: app/controllers/FolderController.php#357 (show)
public function actionEditRole()
{
    if(isset(
$_POST['role'])){
        
$id $_POST['role']['id'];
        
$role=role::model()->findbyPk($id);
        
$this->editSubRole(entity::model()->findbyPk($role->entityId), $role->name$_POST['role']['name']);
        
$role->attributes=$_POST['role'];
        if(
$role->save()){
            
$roles $this->getRolesList();
            
$selectedRole $role->id;
            
$model $this->loadentity($_GET['folderId']);
            
$this->render('selectRole',array('role'=>$role,'roles'=>$roles'selectedRole'=>$selectedRole'model'=>$model));
        }
        
    }
    
}

Edit folder role (old version)

actionFindAllFiles() method
public void actionFindAllFiles()
Source Code: app/controllers/FolderController.php#1021 (show)
public function actionFindAllFiles(){
    
    if(isset(
$_POST['entity']['keyword'])||isset($_GET['keyword']))
        
$keyword = ($_POST['entity']['keyword']!=null) ? $_POST['entity']['keyword'] : $_GET['keyword'] ;
    if(isset(
$_POST['standardMetadata'])||isset($_GET['standard']))
        
$standard = ($_POST['standardMetadata']['id']!=null) ? $_POST['standardMetadata']['id'] : $_GET['standard'] ;
    if(isset(
$_POST['entityType'])||isset($_GET['entityType']))
        
$entityType = ($_POST['entityType']['id']!=null) ? $_POST['entityType']['id'] : $_GET['entityType'] ;

    
$user Yii::app()->user;
    
$isAdmin=0;
    if(
$user->checkAccess("UserAdmin"))
         
$isAdmin 1;
    
$sql2 "(SELECT tt.id AS t0_c0, tt.typeId AS t0_c1, tt.name AS t0_c2, relation1.id AS t1_c0, relation1.entity1 AS t1_c1, relation1.entity2 AS t1_c2, relation1.name AS t1_c3, relation1.content AS t1_c4, relation1.typeId AS t1_c5, entity2entity.id AS t2_c0, entity2entity.typeId AS t2_c1, entity2entity.name AS t2_c2, relation1d.id AS t3_c0, relation1d.entity1 AS t3_c1, relation1d.entity2 AS t3_c2, relation1d.name AS t3_c3, relation1d.content AS t3_c4, relation1d.typeId AS t3_c5 FROM entity tt  LEFT OUTER JOIN relation relation1 ON (relation1.entity1=tt.id)  LEFT OUTER JOIN entity entity2entity ON (relation1.entity2=entity2entity.id)  LEFT OUTER JOIN relation relation1d ON (relation1d.entity1=entity2entity.id)  LEFT OUTER JOIN role role ON (role.entityId=tt.id)  LEFT OUTER JOIN roleAccess roleAccess ON (roleAccess.roleId=role.id)  LEFT OUTER JOIN userRole userRole ON (userRole.roleId=role.id)  LEFT OUTER JOIN publicAccess publicAccess ON (publicAccess.entityId=tt.id) WHERE (t.typeId=2 and relation1.typeId=1 and relation1d.typeId=1 and t.id=tt.id AND ((roleAccess.access>=".roleAccess::READ.' AND userRole.userId='.$user->id.') OR (publicAccess.access=1 AND userRole.userId='.$user->id.") or (".$isAdmin."))))";
    
    if(
$keyword!=null&&trim($keyword)!=""){
        if(
$entityType!="2001"){
            if(
$entityType==entityType::FOLDER_TYPE)
                
$condition='(t.typeId='.entityType::FOLDER_TYPE.' and relation1.typeId='.relationType::IS_PART_OF.') AND ';
            else
                
$condition='(t.typeId='.$entityType.') AND ';
            
        }else{
            
$condition='((t.typeId='.entityType::FOLDER_TYPE.' and relation1.typeId='.relationType::IS_PART_OF.') or (entityType.type=0 and t.typeId!='.entityType::FOLDER_TYPE.')) AND ';
        }
        if(
$standard!="1001")//search selected metadata standard type
            
$condition=$condition.'(metadata.content like \'%'.$keyword.'%\' OR t.name like \'%'.$keyword.'%\') AND fileMetadataType.mapId='.$standard.' AND ((roleAccess.access>='.roleAccess::READ.' AND userRole.userId='.$user->id.') OR (publicAccess.access=1 AND userRole.userId='.$user->id.') OR ('.$isAdmin.'))';
        else
            
$condition=$condition.'(metadata.content like \'%'.$keyword.'%\' OR t.name like \'%'.$keyword.'%\') AND ((roleAccess.access>='.roleAccess::READ.' AND userRole.userId='.$user->id.') OR (publicAccess.access=1 AND userRole.userId='.$user->id.') OR ('.$isAdmin.'))';
    }else{
        
$condition='(t.typeId=1000)';//return no results if keyword is null
        
    
}
    
$criteria=new CDbCriteria;
    
$criteria->condition $condition.'  AND NOT EXISTS '.$sql2;
    
$criteria->distinct true;
    
$criteria->select = array("t.*");
     
    
$criteria->join "LEFT OUTER JOIN relation relation1 ON (relation1.entity1=t.id)  LEFT OUTER JOIN entity entity2entity ON (relation1.entity2=entity2entity.id)  LEFT OUTER JOIN relation relation1d ON (relation1d.entity1=entity2entity.id) LEFT OUTER JOIN metadata metadata ON (metadata.entityId=t.id)  LEFT OUTER JOIN metadataType fileMetadataType ON (metadata.typeId=fileMetadataType.id)  LEFT OUTER JOIN role role ON (role.entityId=t.id)  LEFT OUTER JOIN roleAccess roleAccess ON (roleAccess.roleId=role.id)  LEFT OUTER JOIN userRole userRole ON (userRole.roleId=role.id)  LEFT OUTER JOIN publicAccess publicAccess ON (publicAccess.entityId=t.id) ";
    
$criteria->with = array('entityType'=>array('select'=>array('id''name''type')));
    
$criteria->together true;
    
$pages=new CPagination(entity::model()->count($criteria));
    
$pages->params = array('keyword'=>$keyword'standard'=>$standard'entityType'=>$entityType);
    
$pages->pageSize=self::PAGE_SIZE;
    
$pages->applyLimit($criteria);
    
    
    
$models entity::model()->findAll($criteria);
    
    
    
$this->render('findAllFiles',array(
        
'models'=>$models,
        
'pages'=>$pages,
        
'keyword'=>$keyword,
    ));


}

Search all files in folder

actionList() method
public void actionList()
Source Code: app/controllers/FolderController.php#878 (show)
public function actionList()
{
    
//$sql2 = "(SELECT tt.id AS t0_c0, tt.typeId AS t0_c1, tt.name AS t0_c2, relation1.id AS t1_c0, relation1.entity1 AS t1_c1, relation1.entity2 AS t1_c2, relation1.name AS t1_c3, relation1.content AS t1_c4, relation1.typeId AS t1_c5, entity2entity.id AS t2_c0, entity2entity.typeId AS t2_c1, entity2entity.name AS t2_c2, relation1d.id AS t3_c0, relation1d.entity1 AS t3_c1, relation1d.entity2 AS t3_c2, relation1d.name AS t3_c3, relation1d.content AS t3_c4, relation1d.typeId AS t3_c5 FROM entity tt  LEFT OUTER JOIN relation relation1 ON (relation1.entity1=tt.id)  LEFT OUTER JOIN entity entity2entity ON (relation1.entity2=entity2entity.id)  LEFT OUTER JOIN relation relation1d ON (relation1d.entity1=entity2entity.id)  WHERE (t.typeId=2 and relation1.typeId=1 and relation1d.typeId=1 and t.id=tt.id))";
    
$user Yii::app()->user;
    
$isAdmin=0;
    if(
$user->checkAccess("UserAdmin"))
         
$isAdmin 1;
    
    
$sql2 "(SELECT tt.id AS t0_c0, tt.typeId AS t0_c1, tt.name AS t0_c2, relation1.id AS t1_c0, relation1.entity1 AS t1_c1, relation1.entity2 AS t1_c2, relation1.name AS t1_c3, relation1.content AS t1_c4, relation1.typeId AS t1_c5, entity2entity.id AS t2_c0, entity2entity.typeId AS t2_c1, entity2entity.name AS t2_c2, relation1d.id AS t3_c0, relation1d.entity1 AS t3_c1, relation1d.entity2 AS t3_c2, relation1d.name AS t3_c3, relation1d.content AS t3_c4, relation1d.typeId AS t3_c5 FROM entity tt  LEFT OUTER JOIN relation relation1 ON (relation1.entity1=tt.id)  LEFT OUTER JOIN entity entity2entity ON (relation1.entity2=entity2entity.id)  LEFT OUTER JOIN relation relation1d ON (relation1d.entity1=entity2entity.id)  LEFT OUTER JOIN role role ON (role.entityId=tt.id)  LEFT OUTER JOIN roleAccess roleAccess ON (roleAccess.roleId=role.id)  LEFT OUTER JOIN userRole userRole ON (userRole.roleId=role.id)  LEFT OUTER JOIN publicAccess publicAccess ON (publicAccess.entityId=tt.id) WHERE (t.typeId=2 and relation1.typeId=1 and relation1d.typeId=1 and t.id=tt.id AND ((roleAccess.access>=".roleAccess::READ.' AND userRole.userId='.$user->id.') OR (publicAccess.access=1 AND userRole.userId='.$user->id.") OR (".$isAdmin."))))";
    
    
$criteria=new CDbCriteria;
    
$condition='(t.typeId='.entityType::FOLDER_TYPE.' and relation1.typeId='.relationType::IS_PART_OF.' AND ((roleAccess.access>='.roleAccess::READ.' AND userRole.userId='.$user->id.') OR (publicAccess.access=1 AND userRole.userId='.$user->id.') OR ('.$isAdmin.')))  AND NOT EXISTS '.$sql2;
    
$criteria->condition $condition;
    
$criteria->order ="t.name";
    
$criteria->distinct true;
    
$criteria->select = array("t.*");
    
$criteria->join "LEFT OUTER JOIN relation relation1 ON (relation1.entity1=t.id)  LEFT OUTER JOIN entity entity2entity ON (relation1.entity2=entity2entity.id)  LEFT OUTER JOIN relation relation1d ON (relation1d.entity1=entity2entity.id) LEFT OUTER JOIN role role ON (role.entityId=t.id)  LEFT OUTER JOIN roleAccess roleAccess ON (roleAccess.roleId=role.id)  LEFT OUTER JOIN userRole userRole ON (userRole.roleId=role.id)  LEFT OUTER JOIN publicAccess publicAccess ON (publicAccess.entityId=t.id) ";
    
$criteria->together true;
    
    
$pages=new CPagination(entity::model()->count($criteria));
    
$pages->pageSize=self::PAGE_SIZE;
    
$pages->applyLimit($criteria);
    
    
$models entity::model()->findAll($criteria);

    
$this->render('list',array(
        
'models'=>$models,
        
'pages'=>$pages,
    ));

}

Lists all folder models according to user permission.

actionPermission() method
public void actionPermission()
Source Code: app/controllers/FolderController.php#180 (show)
public function actionPermission(){
    
$model $this->loadentity();
    
    
$criteria=new CDbCriteria;
    
$condition='entityId='.$model->id;
    
$criteria->condition $condition;
    
$publicAccess=publicAccess::model()->find($criteria);
    
    
$hasPublicAccess=0;
    if(
$publicAccess!=null&&$publicAccess->entityId!=null){
        
$hasPublicAccess $publicAccess->access;
    }else{
        
$publicAccess = new publicAccess;
        
$publicAccess->entityId $model->id;
        
$publicAccess->entityType $model->typeId;
        
$publicAccess->access=$hasPublicAccess;
        
$publicAccess->save();
        
$this->createSubPublicAccess($model$hasPublicAccess);
        
    }
    if(isset(
$_POST['permission'])&&isset($_POST['hasPublicAccess'])&&$_POST['hasPublicAccess']=="1"){
        
$hasPublicAccess=1;
        
$publicAccess->access=$hasPublicAccess;
        
$publicAccess->save();
        
$this->editSubPublicAccess($model,$hasPublicAccess);
        
    }else if(isset(
$_POST['permission'])&&$_POST['hasPublicAccess']===null){        
        
$hasPublicAccess=0;
        
$publicAccess->access=$hasPublicAccess;
        
$publicAccess->save();
        
$this->editSubPublicAccess($model,$hasPublicAccess);
    }

    
    
$this->render('permission', array('model'=>$model'hasPublicAccess'=>$hasPublicAccess));
}

permission setting entry page

actionRoleAccess() method
public void actionRoleAccess()
Source Code: app/controllers/FolderController.php#501 (show)
public function actionRoleAccess(){
    
$roles $this->getRoleModels();
    if(isset(
$_POST['ac'])){
        foreach(
$roles as $role){
            
$roleAccesses $role->roleAccess;
            foreach(
$roleAccesses as $access){
                
$access->delete();
            }
            
$this->deleteSubRoleAccess(entity::model()->findbyPk($role->entityId), $role);
            if(isset(
$_POST['ac'][$role->id])){
                
$access = new roleAccess;
                
$access->roleId $role->id;
                
$access->access $_POST['ac'][$role->id];
                
$access->save();
                
$this->createSubRoleAccess(entity::model()->findbyPk($role->entityId), $access);
            }
        }
        
$roles $this->getRoleModels();
    }
    
$model $this->loadentity($_GET['folderId']);
    
$this->render('roleAccess', array('roles'=>$roles'model'=>$model));
}

assign read-1, write-2, admin-3 premission to folder role

actionSearch() method
public void actionSearch()
Source Code: app/controllers/FolderController.php#913 (show)
public function actionSearch()
{
            
// renders the view file 'protected/views/site/index.php'
    // using the default layout 'protected/views/layouts/main.php'
//Yii::app()->setGlobalState('currentFolder',$id);
    
$folder $this->loadentity();
    
$currentFolder Yii::app()->getGlobalState('currentFolder');
    
$searchFolder Yii::app()->getGlobalState('searchFolder');
    
$form = new SearchForm();
    
$condition Yii::app()->getGlobalState('searchCondition2');
    if(
$currentFolder!=$searchFolder){
        
$criteria=new CDbCriteria;
        
$condition='t.typeId='.entityType::IMAGE_TYPE;
        
$condition=$condition.' AND relation1.entity2='.$currentFolder;
        
$condition=$condition.' AND relation1.typeId='.relationType::IS_PART_OF;
        
Yii::app()->setGlobalState('searchFolder',$currentFolder);
        
$criteria->condition $condition;   echo $criteria->select.$criteria->condition;
        
$pages=new CPagination(entity::model()->with('relation1','metadata')->together()->count($criteria));
        
$pages->pageSize=self::PAGE_SIZE;
        
$pages->applyLimit($criteria);

        
$models=entity::model()->with('relation1','metadata')->together()->findAll($criteria);

        
$this->render('ssearch',array(
            
'model'=>$folder,
            
'filemodels'=>$models,
            
'pages'=>$pages,
            
'form'=>$form,'condition'=>$condition,
        ));

    }else if(isset(
$_POST['SearchForm'])){
        
$form->attributes=$_POST['SearchForm'];

        if(
$form->validate())
        {
              
$keyword $form->keyword;
             
              
$criteria=new CDbCriteria;
            
$condition='t.typeId='.entityType::IMAGE_TYPE;
            
$condition=$condition.' AND relation1.entity2='.$form->id;
            
$condition=$condition.' AND relation1.typeId='.relationType::IS_PART_OF;
            
$condition=$condition.' AND metadata.typeId=3';
            
$condition=$condition.' AND metadata.content like \'%'.$keyword.'%\'';
            
Yii::app()->setGlobalState('searchCondition2',$condition);
            
Yii::app()->setGlobalState('searchFolder',$form->id);
            
$criteria->condition $condition;   echo $criteria->select.$criteria->condition;
            
$pages=new CPagination(entity::model()->with('relation1','metadata')->together()->count($criteria));
            
$pages->pageSize=self::PAGE_SIZE;
            
$pages->applyLimit($criteria);

            
$models=entity::model()->with('relation1','metadata')->together()->findAll($criteria);

             
              
$this->render('ssearch',array(
                   
'model'=>$folder,
                  
'filemodels'=>$models,
                  
'pages'=>$pages,
                  
'form'=>$form,'condition'=>$condition,
              ));
        }else 
$this->render('ssearch',array('form'=>$form));
      }else if(
$condition!=null&&trim($condition)!=''){
        
$criteria=new CDbCriteria;
        
$criteria->condition $condition;   echo $criteria->select.$criteria->condition;
        
$pages=new CPagination(entity::model()->with('relation1','metadata')->together()->count($criteria));
        
$pages->pageSize=self::PAGE_SIZE;
        
$pages->applyLimit($criteria);

        
$models=entity::model()->with('relation1','metadata')->together()->findAll($criteria);

        
$this->render('ssearch',array(
            
'model'=>$folder,
            
'filemodels'=>$models,
            
'pages'=>$pages,
            
'form'=>$form,'condition'=>$condition,
        ));
    }
        else 
$this->render('ssearch',array('form'=>$form'model'=>$folder));
}

Search in folder.

actionSelectRole() method
public void actionSelectRole()
Source Code: app/controllers/FolderController.php#474 (show)
public function actionSelectRole()
{
    
$model $this->loadentity($_GET['folderId']);
    if(isset(
$_GET['id'])){
        
$id $_GET['id'];
        
$role=role::model()->findbyPk($id);
        
$roles $this->getRolesList();
        
        
$this->render('selectRole',array('role'=>$role,'roles'=>$roles'selectedRole'=>$role->id'model'=>$model));
                        
    }else{                
        
$roles $this->getRolesList();
        
$role = new role();
        
$i=0;
        foreach(
$roles as $id=>$name):
            
$selectedRole=$id;
            
$role=role::model()->findbyPk($id);
            
            
$i++;
            if(
$i>0)break;
        endforeach;                
        
$this->render('selectRole',array('role'=>$role,'roles'=>$roles'selectedRole'=>$role->id'model'=>$model));
    }
}

Edits selected role or create new role

actionShow() method
public void actionShow()
Source Code: app/controllers/FolderController.php#73 (show)
public function actionShow()
{    
    
//load files/folders based on user permission
    
$filefolders $this->loadfilefoldersWP();

    
$this->render('show',array('model'=>$this->loadentity(),'filefoldersmodel'=>$filefolders[0],'filesmodel'=>$filefolders[1],'subfoldersmodel'=>$filefolders[2], 'pages'=>$filefolders[3], 'record'=>$_GET['record']));
}

Shows a particular folder model.

actionShowimagetbn() method
public void actionShowimagetbn()
Source Code: app/controllers/FolderController.php#84 (show)
public function actionShowimagetbn()
{    
    
    require_once(
Yii::app()->basePath.'/../lib/PThumb.lib.php');
    
$pThumb = new PThumb(1);                        
    if(!
$pThumb->isError()&&$_GET['path']&&$_GET['name']){        
        
$path $_GET['path'];
        
$name $_GET['name'];
        
$pThumb->use_cache false;
        
$pThumb->cache_dir Yii::app()->params['appPath']."/images/cache/";    
        if(
file_exists(Yii::app()->params['ajPath']."/data/".$path.$name))
            
$pThumb->fit_thumbnail(Yii::app()->params['ajPath']."/data/".$path.$name200200);
        else
            
$pThumb->fit_thumbnail(Yii::app()->params['appPath']."/images/icon/record.png"200200);
        if(
$pThumb->isError()){
            
            
print_r($pThumb->error_array);
        }
        exit(
0);
    }else 
        
$pThumb->fit_thumbnail(Yii::app()->params['appPath']."/images/icon/record.png"200200);

}

Shows image thumbnail 200*200

actionShowvideotbn() method
public void actionShowvideotbn()
Source Code: app/controllers/FolderController.php#111 (show)
public function actionShowvideotbn()
{    
    
    
$ffmpeg_path "/usr/bin/ffmpeg";
    if (
file_exists($ffmpeg_path)&&$_GET['id']){
        
$id $_GET['id'];
        
$thumbpath Yii::app()->params['ajPath']."/tmp/videothumbs/".$id.".jpg";
        if(!
file_exists($thumbpath)){
            
$path $_GET['path'];
            
$name $_GET['name'];
            if(
$_GET['path']&&$_GET['name']){
                
$options "-an -y -f mjpeg -ss 2 -s 200x150 -vframes 1 ";
                
$filepath Yii::app()->params['ajPath']."/data/".$path.$name;
                
$thumbpath Yii::app()->params['ajPath']."/tmp/videothumbs/".$id.".jpg";
                
$command $ffmpeg_path " -i '" $filepath "' " $options " " $thumbpath;
                
exec($command$output);
            }
        }
        require_once(
Yii::app()->basePath.'/../lib/PThumb.lib.php');
        
$pThumb = new PThumb(1);
        if(
file_exists($thumbpath))
            
$pThumb->fit_thumbnail($thumbpath200);
        else     
            
$pThumb->fit_thumbnail(Yii::app()->params['appPath']."/images/icon/record.png"200200);
        if(
$pThumb->isError()){
            
print_r($pThumb->error_array);
        }
        exit(
0);
    }else 
        
$pThumb->fit_thumbnail(Yii::app()->params['appPath']."/images/icon/record.png"200200);
    
    
/*$ffmpeg_path = "/usr/bin/ffmpeg";
    if (file_exists($ffmpeg_path)&&$_GET['path']&&$_GET['name']&&$_GET['id']){
        $path = $_GET['path'];
        $name = $_GET['name'];
        $id = $_GET['id'];
        $options = "-an -y -f mjpeg -ss 2 -s 200x150 -vframes 1 ";
        $filepath = Yii::app()->params['ajPath']."/files/".$path.$name;
        $thumbpath = Yii::app()->params['appPath']."/tmp/".$id.".jpg";
        $command = $ffmpeg_path . " -i '" . $filepath . "' " . $options . " " . $thumbpath;
        exec($command, $output);
        require_once(Yii::app()->basePath.'/../lib/PThumb.lib.php');
        $pThumb = new PThumb(1);
        $pThumb->fit_thumbnail($thumbpath, 200);
        if($pThumb->isError()){
            print_r($pThumb->error_array);
        }
        exit(0);
    }*/
}

Shows video thumbnail from first frame of video

actionUpdate() method
public void actionUpdate()
Source Code: app/controllers/FolderController.php#847 (show)
public function actionUpdate()
{
    
$model=$this->loadentity();
    if(isset(
$_POST['entity']))
    {
        
$model->attributes=$_POST['entity'];
        if(
$model->save())
            
$this->redirect(array('show','id'=>$model->id));
    }
    
$this->render('update',array('model'=>$model));
}

Updates a particular folder model. (old version) If update is successful, the browser will be redirected to the 'show' page.

actionUserRole() method
public void actionUserRole()
Source Code: app/controllers/FolderController.php#579 (show)
public function actionUserRole(){
    
$roles $this->getRoleModels();
    
$criteria=new CDbCriteria;
    
$pages=new CPagination(user::model()->count($criteria));
    
$pages->pageSize=self::PAGE_SIZE;
    
$pages->applyLimit($criteria);

    
$models=user::model()->findAll($criteria);
    
    if(isset(
$_POST['ur'])){
        foreach(
$roles as $role){
            
$userRoles $role->userRole;
            foreach(
$userRoles as $userRole){
                
$userRole->delete();
            }
            
$this->deleteSubUserRole(entity::model()->findbyPk($role->entityId), $role$user->id);
            foreach(
$models as $user){
                if(isset(
$_POST['ur'][$role->id][$user->id])&&$_POST['ur'][$role->id][$user->id]=="1"){
                    
$userRole = new userRole;
                    
$userRole->roleId $role->id;
                    
$userRole->userId $user->id;
                    
$userRole->save();
                    
$this->createSubUserRole(entity::model()->findbyPk($role->entityId), $role$user->id);
                }
            }
        }
        
$roles $this->getRoleModels();
        
    }
    
$model $this->loadentity($_GET['folderId']);
    
$this->render('userRole',array(
        
'models'=>$models,
        
'pages'=>$pages,
        
'roles'=>$roles,
        
'model'=>$model
    
));
}

Assign user to folder role (old version)

actionUserRole2() method
public void actionUserRole2()
Source Code: app/controllers/FolderController.php#619 (show)
public function actionUserRole2(){
    
$roles $this->getRoleModels();
    
$criteria=new CDbCriteria;
    
$prjId Yii::app()->getGlobalState('currentProject');
        
//$folderId = Yii::app()->getGlobalState('currentFolder');
        //$folderId = entity::model()->findbyPk($folderId);


        
$folderId $_GET['folderId'];

        
//$folderId = "2";
        //$folderId = entity::model()->findbyPk($role->entityId);

    
$condition='role.entityId='.$folderId.' and role.entityType='.entityType::FOLDER_TYPE;

    
//$condition='role.entityId=2 and role.entityType='.entityType::FOLDER_TYPE;
    
$criteria->condition $condition;
    
$pages=new CPagination(user::model()->with('userRole''userRole.role' )->together()->count($criteria));
    
$pages->pageSize=self::PAGE_SIZE;
    
$pages->applyLimit($criteria);
    
$models=user::model()->with('userRole''userRole.role' )->together()->findAll($criteria);
    
    if(isset(
$_POST['ur'])){
        foreach(
$roles as $role){
            
$userRoles $role->userRole;
            foreach(
$userRoles as $userRole){
                
$userRole->delete();
            }
            
$this->deleteSubUserRole(entity::model()->findbyPk($role->entityId), $role$user->id);
            
            foreach(
$models as $user){

                if(isset(
$_POST['ur'][$role->id][$user->id])&&$_POST['ur'][$role->id][$user->id]=="1"){
                    
$userRole = new userRole;
                    
$userRole->roleId $role->id;
                    
$userRole->userId $user->id;
                    
//$userRole->entityId = $role->entityId;
                    
$userRole->save();
                    
$this->createSubUserRole(entity::model()->findbyPk($role->entityId), $role$user->id);
                }
            }
        }

        
$roles $this->getRoleModels();
        
$criteria=new CDbCriteria;
        
$prjId Yii::app()->getGlobalState('currentProject');
        
//$folderId = entity::model()->findbyPk($role->entityId);
        //$folderId = Yii::app()->getGlobalState('currentFolder');
        //$folder = entity::model()->findbyPk($folderId);

            
$folderId $_GET['folderId'];
            
//$folderId = "2";

        
$condition='role.entityId='.$folderId.' and role.entityType='.entityType::FOLDER_TYPE;
        
//$condition='role.entityId=2 and role.entityType='.entityType::FOLDER_TYPE;
        
$criteria->condition $condition;
        
$pages=new CPagination(user::model()->with('userRole''userRole.role' )->together()->count($criteria));
        
$pages->pageSize=self::PAGE_SIZE;
        
$pages->applyLimit($criteria);
        
$models=user::model()->with('userRole''userRole.role' )->together()->findAll($criteria);
    }
    
    
    
//$model = $this->loadentity();
    
$model $this->loadentity($_GET['folderId']);
    
$this->render('userRole2',array(
            
'models'=>$models,
            
'pages'=>$pages,
            
'roles'=>$roles,
            
'model'=>$model
    
));

/*         $criteria=new CDbCriteria;
    $pages=new CPagination(user::model()->count($criteria));
    $pages->pageSize=self::PAGE_SIZE;
    $pages->applyLimit($criteria);

    $models=user::model()->findAll($criteria);
    
    if(isset($_POST['ur'])){
        foreach($roles as $role){
            $userRoles = $role->userRole;
            foreach($userRoles as $userRole){
                $userRole->delete();
            }
            $this->deleteSubUserRole(entity::model()->findbyPk($role->entityId), $role, $user->id);
            foreach($models as $user){
                if(isset($_POST['ur'][$role->id][$user->id])&&$_POST['ur'][$role->id][$user->id]=="1"){
                    $userRole = new userRole;
                    $userRole->roleId = $role->id;
                    $userRole->userId = $user->id;
                    $userRole->save();
                    $this->createSubUserRole(entity::model()->findbyPk($role->entityId), $role, $user->id);
                }
            }
        }
        $roles = $this->getRoleModels();
        
    }
    $model = $this->loadentity($_GET['folderId']);
    $this->render('userRole',array(
        'models'=>$models,
        'pages'=>$pages,
        'roles'=>$roles,
        'model'=>$model
    ));
*/
}

Show folder role and user. Assign folder role to existing folder user

actionUserRoleAdd() method
public void actionUserRoleAdd()
Source Code: app/controllers/FolderController.php#731 (show)
public function actionUserRoleAdd(){
    
$model $this->loadentity($_GET['folderId']);
    if(
$_GET["id"]=="addcancel"){
        
$this->renderPartial('_userRoleAddCancel',array(                    
                
'model'=>$model,
        ));
    }else{
        if(isset(
$_GET["userName"])&&isset($_GET['uradd'])){
            
$condition='t.username="'.trim($_GET["userName"]).'"';
            
$criteria=new CDbCriteria;
            
$criteria->condition $condition;
            
            
$user=user::model()->find($criteria);
            if(
$user!=null&&$user->id!=null){
                foreach(
$_GET['uradd'] as $roleId=>$uradd){
                    if(
$uradd){
                        
$userRole = new userRole;
                        
$userRole->roleId $roleId;
                        
$userRole->userId $user->id;
                        
$userRole->save();
                    }
                }
                
$usertemp = new user;
            }else{
                
$error="The user name doesn't exist.";
                
$usertemp = new user;
                
$usertemp->addError("username"$error);
                
            }
            
$roles $this->getRoleModels();
            
$criteria=new CDbCriteria;
            
$prjId Yii::app()->getGlobalState('currentProject');
            
$condition='role.entityId='.$prjId.' and role.entityType='.entityType::FOLDER_TYPE;
            
$criteria->condition $condition;
            
$pages=new CPagination(user::model()->with('userRole''userRole.role' )->together()->count($criteria));
            
$pages->pageSize=self::PAGE_SIZE;
            
$pages->applyLimit($criteria);
            
$models=user::model()->with('userRole''userRole.role' )->together()->findAll($criteria);
            
$this->renderPartial('_userRoleAddR',array(
                    
'models'=>$models,
                    
'pages'=>$pages,
                    
'roles'=>$roles,
                    
'model'=>$model,
                    
'user'=>$usertemp
            
));
        }else{
            
$roles $this->getRoleModels();    
                        
            
$this->renderPartial('_userRoleAdd',array(
                    
'roles'=>$roles,
                    
'model'=>$model,
                    
'user'=>new user
            
));
        }
    }
}

Add new user--folder role relationship

filters() method
public array filters()
{return} array action filters
Source Code: app/controllers/FolderController.php#23 (show)
public function filters()
{
    return array(
        
'accessControl'// perform access control for CRUD operations
    
);
}

getRoleModels() method
public void getRoleModels()
Source Code: app/controllers/FolderController.php#1258 (show)
public function getRoleModels(){
    
$prjId Yii::app()->getGlobalState('currentFolder');
    
$criteria=new CDbCriteria;
    
$condition='entityId='.$prjId.' and entityType='.entityType::FOLDER_TYPE;
    
$criteria->condition $condition;
    
$models=role::model()->findAll($criteria);    
    return 
$models;
}

Get roles models by entity(file) id and entity(file) type.

getRolesList() method
public void getRolesList()
Source Code: app/controllers/FolderController.php#1241 (show)
public function getRolesList(){
    
$prjId Yii::app()->getGlobalState('currentFolder');
    
$criteria=new CDbCriteria;
    
$condition='entityId='.$prjId.' and entityType='.entityType::FOLDER_TYPE;
    
$criteria->condition $condition;
    
$models=role::model()->findAll($criteria);
    
$roles = array();
    foreach(
$models as $model):
        
$roles[$model->id]=$model->name;
    endforeach;
    return 
$roles;
}

Get roles array by entity(file) id and entity(file) type.

hasAccess() method
public void hasAccess(unknown_type $user, unknown_type $access)
$user unknown_type
$access unknown_type
Source Code: app/controllers/FolderController.php#1305 (show)
public function hasAccess($user$access){
    if(isset(
$_GET['folderId']))
        
$model $this->loadentity($_GET['folderId']);
    
$folderId Yii::app()->getGlobalState('currentFolder');
    if(
$model!=null){
        
Yii::app()->setGlobalState('currentFolder'$model->id);
        
$folderId $model->id;
    }
    
$hasAccess 0;
    
    if(
$access=="public"&&$folderId!=null){
        
$criteria=new CDbCriteria;
        
$condition='entityId='.$folderId;
        
$criteria->condition $condition;
        
$publicAccess=publicAccess::model()->find($criteria);
        if(
$publicAccess!=null&&$publicAccess->access)
            
$hasAccess=1;
    }else if(
$user!=null&&$user->id!=null&&$folderId!=null){
        
$criteria=new CDbCriteria;
        
$condition='t.entityId='.$folderId.' and userRole.userId='.$user->id;
        
$criteria->condition $condition;
        
$roles=role::model()->with('userRole')->findAll($criteria);
        foreach(
$roles as $role){
            
$roleAccesses $role->roleAccess;
            foreach(
$roleAccesses as $roleAccess){
                if(
$roleAccess->access == $access){
                    
$hasAccess 1;
                }
                
            }
        }
    }
    return 
$hasAccess;
}

hasPrjAdmin() method
public void hasPrjAdmin(model $user)
$user model
Source Code: app/controllers/FolderController.php#1270 (show)
public function hasPrjAdmin($user){
    
$prjId Yii::app()->getGlobalState('currentFolder');
    
$criteria=new CDbCriteria;
    
$condition='t.entityId='.$prjId.' and userRole.userId='.$user->id;
    
$criteria->condition $condition;
    
$roles=role::model()->with('userRole')->findAll($criteria);
    
$hasAdminAccess 0;
    foreach(
$roles as $role){
        
$roleAccesses $role->roleAccess;
        foreach(
$roleAccesses as $roleAccess){
            if(
$roleAccess->access == roleAccess::ADMIN){
                
$hasAdminAccess 1;
            }
            
        }
    }
    return 
$hasAdminAccess;
}

Check if user has folder admin permission

loadentity() method
public void loadentity(integer $id=NULL)
$id integer the primary key value. Defaults to null, meaning using the 'id' GET variable
Source Code: app/controllers/FolderController.php#1085 (show)
public function loadentity($id=null)
{
    
//if($this->_model===null)
    //{
        
if($id!==null || isset($_GET['id'])){
            
$id = ($id!=null) ? $id $_GET['id'];
            
$this->_model=entity::model()->findbyPk($id);
//set current folder id for use in creating file
            
Yii::app()->setGlobalState('currentFolder',$id);
        }if(
$this->_model===null)
            throw new 
CHttpExceptionfile/upload(404,'The requested page does not exist.');
        else return 
$this->_model;
    
//}
    
return $this->_model;
}

Returns the data model based on the primary key given in the GET variable. If the data model is not found, an HTTP exception will be raised.

loadfilefolders() method
public array(file loadfilefolders(integer $id=NULL)
$id integer
{return} array(file models, subfolder models, file&folder models)
Source Code: app/controllers/FolderController.php#1106 (show)
public function loadfilefolders($id=null){

    
//if($this->_filesmodel===null)
    //{
        
if($id!==null || isset($_GET['id'])){
            
$id = ($id!=null) ? $id $_GET['id'];
            
Yii::app()->setGlobalState('currentFolder',$id);
            
$criteria=new CDbCriteria;
            
$condition='t.typeId='.entityType::IMAGE_TYPE.' or t.typeId='.entityType::VIDEO_TYPE.' or t.typeId='.entityType::AUDIO_TYPE.' or t.typeId='.entityType::DOCUMENT_TYPE;
             
$condition=$condition.' AND relation1.entity2='.$id;
             
$condition=$condition.' AND relation1.typeId='.relationType::IS_PART_OF;
            
$criteria->condition $condition;//echo $criteria->select.$criteria->condition;

            
$this->_filesmodel=entity::model()->with('relation1')->together()->findAll($criteria);
        }
        if(
$this->_filesmodel===null)
            throw new 
CHttpExceptionfile(404,'The requested page does not exist.');
    
//}
    //if($this->_subfoldersmodel===null)
    //{
        
if($id!==null || isset($_GET['id'])){
            
$id = ($id!=null) ? $id $_GET['id'];
            
Yii::app()->setGlobalState('currentFolder',$id);
            
$criteria=new CDbCriteria;
            
$condition='t.typeId='.entityType::FOLDER_TYPE;
             
$condition=$condition.' AND relation1.entity2='.$id;
             
$condition=$condition.' AND relation1.typeId='.relationType::IS_PART_OF;
            
$criteria->condition $condition;//echo $criteria->select.$criteria->condition;

            
$this->_subfoldersmodel=entity::model()->with('relation1')->together()->findAll($criteria);
        }if(
$this->_subfoldersmodel===null)
            throw new 
CHttpExceptionfile/upload(404,'The requested page does not exist.');
    
//}
        
if($id!==null || isset($_GET['id'])){
            
$id = ($id!=null) ? $id $_GET['id'];
            
Yii::app()->setGlobalState('currentFolder',$id);
            
$criteria=new CDbCriteria;
            
$condition='(t.typeId='.entityType::IMAGE_TYPE .' or t.typeId='.entityType::VIDEO_TYPE.' or t.typeId='.entityType::AUDIO_TYPE.' or t.typeId='.entityType::DOCUMENT_TYPE.' or t.typeId='.entityType::FOLDER_TYPE.')';
             
$condition=$condition.' AND relation1.entity2='.$id;
             
$condition=$condition.' AND relation1.typeId='.relationType::IS_PART_OF;
            
$criteria->condition $condition;//echo $criteria->select.$criteria->condition;
            
$pages=new CPagination(entity::model()->with('relation1')->together()->count($criteria));
            
$pages->pageSize=self::PAGE_SIZE;
            
$pages->applyLimit($criteria);
            
$this->_filefoldersmodel entity::model()->with('relation1')->together()->findAll($criteria);
        }if(
$this->_filefoldersmodel===null)
            throw new 
CHttpExceptionfile/upload(404,'The requested page does not exist.');
    return array(
$this->_filefoldersmodel,$this->_filesmodel,$this->_subfoldersmodel$pages, ) ;

}

Get file, subfolder, file&subfolder models according to folder id

loadfilefoldersWP() method
public array(file loadfilefoldersWP(integer $id=NULL)
$id integer
{return} array(file models, subfolder models, file&folder models)
Source Code: app/controllers/FolderController.php#1162 (show)
public function loadfilefoldersWP($id=null){
    
$user Yii::app()->user;
    
$isAdmin=0;
    if(
$user->checkAccess("UserAdmin"))
        
$isAdmin 1;
    
//permission condition
    
$condition0='((roleAccess.access>='.roleAccess::READ.' AND userRole.userId='.$user->id.') OR (publicAccess.access=1 AND userRole.userId='.$user->id.') OR ('.$isAdmin.')) AND ';
    
    
//if($this->_filesmodel===null)
    //{
        
if($id!==null || isset($_GET['id'])){
            
$id = ($id!=null) ? $id $_GET['id'];
            
Yii::app()->setGlobalState('currentFolder',$id);
            
$criteria=new CDbCriteria;
            
$condition=$condition0.'t.typeId='.entityType::IMAGE_TYPE.' or t.typeId='.entityType::VIDEO_TYPE.' or t.typeId='.entityType::AUDIO_TYPE.' or t.typeId='.entityType::DOCUMENT_TYPE;
            
$condition=$condition.' AND relation1.entity2='.$id;
            
$condition=$condition.' AND relation1.typeId='.relationType::IS_PART_OF;
            
$criteria->condition $condition;//echo $criteria->select.$criteria->condition;
                            
            
$criteria->order ="t.name";
            
$criteria->distinct true;
            
$criteria->select = array("t.*");
            
$criteria->join "LEFT OUTER JOIN relation relation1 ON (relation1.entity1=t.id)  LEFT OUTER JOIN entity entity2entity ON (relation1.entity2=entity2entity.id)  LEFT OUTER JOIN relation relation1d ON (relation1d.entity1=entity2entity.id) LEFT OUTER JOIN role role ON (role.entityId=t.id)  LEFT OUTER JOIN roleAccess roleAccess ON (roleAccess.roleId=role.id)  LEFT OUTER JOIN userRole userRole ON (userRole.roleId=role.id)  LEFT OUTER JOIN publicAccess publicAccess ON (publicAccess.entityId=t.id) ";
            
$criteria->together true;                
            
            
$this->_filesmodel=entity::model()->findAll($criteria);
        }if(
$this->_filesmodel===null)
            throw new 
CHttpExceptionfile(404,'The requested page does not exist.');
    
//}
    //if($this->_subfoldersmodel===null)
    //{
        
if($id!==null || isset($_GET['id'])){
            
$id = ($id!=null) ? $id $_GET['id'];
            
Yii::app()->setGlobalState('currentFolder',$id);
            
$criteria=new CDbCriteria;
            
$condition=$condition0.'t.typeId='.entityType::FOLDER_TYPE;
            
$condition=$condition.' AND relation1.entity2='.$id;
            
$condition=$condition.' AND relation1.typeId='.relationType::IS_PART_OF;
            
$criteria->condition $condition;//echo $criteria->select.$criteria->condition;
            
            
$criteria->order ="t.name";
            
$criteria->distinct true;
            
$criteria->select = array("t.*");
            
$criteria->join "LEFT OUTER JOIN relation relation1 ON (relation1.entity1=t.id)  LEFT OUTER JOIN entity entity2entity ON (relation1.entity2=entity2entity.id)  LEFT OUTER JOIN relation relation1d ON (relation1d.entity1=entity2entity.id) LEFT OUTER JOIN role role ON (role.entityId=t.id)  LEFT OUTER JOIN roleAccess roleAccess ON (roleAccess.roleId=role.id)  LEFT OUTER JOIN userRole userRole ON (userRole.roleId=role.id)  LEFT OUTER JOIN publicAccess publicAccess ON (publicAccess.entityId=t.id) ";
            
$criteria->together true;
            
            
$this->_subfoldersmodel=entity::model()->findAll($criteria);
        }if(
$this->_subfoldersmodel===null)
            throw new 
CHttpExceptionfile/upload(404,'The requested page does not exist.');
    
//}
    
if($id!==null || isset($_GET['id'])){
        
$id = ($id!=null) ? $id $_GET['id'];
        
Yii::app()->setGlobalState('currentFolder',$id);
        
$criteria=new CDbCriteria;
        
$condition=$condition0.'(t.typeId='.entityType::IMAGE_TYPE .' or t.typeId='.entityType::VIDEO_TYPE.' or t.typeId='.entityType::AUDIO_TYPE.' or t.typeId='.entityType::DOCUMENT_TYPE.' or t.typeId='.entityType::FOLDER_TYPE.')';
        
$condition=$condition.' AND relation1.entity2='.$id;
        
$condition=$condition.' AND relation1.typeId='.relationType::IS_PART_OF;
        
$criteria->condition $condition;//echo $criteria->select.$criteria->condition;
        
        
$criteria->order ="t.name";
        
$criteria->distinct true;
        
$criteria->select = array("t.*");
        
$criteria->join "LEFT OUTER JOIN relation relation1 ON (relation1.entity1=t.id)  LEFT OUTER JOIN entity entity2entity ON (relation1.entity2=entity2entity.id)  LEFT OUTER JOIN relation relation1d ON (relation1d.entity1=entity2entity.id) LEFT OUTER JOIN role role ON (role.entityId=t.id)  LEFT OUTER JOIN roleAccess roleAccess ON (roleAccess.roleId=role.id)  LEFT OUTER JOIN userRole userRole ON (userRole.roleId=role.id)  LEFT OUTER JOIN publicAccess publicAccess ON (publicAccess.entityId=t.id) ";
        
$criteria->together true;
        
        
$pages=new CPagination(entity::model()->count($criteria));
        
$pages->pageSize=self::PAGE_SIZE;
        
$pages->applyLimit($criteria);
        
$this->_filefoldersmodel entity::model()->findAll($criteria);
    }if(
$this->_filefoldersmodel===null)
        throw new 
CHttpExceptionfile/upload(404,'The requested page does not exist.');
    return array(
$this->_filefoldersmodel,$this->_filesmodel,$this->_subfoldersmodel$pages, ) ;

}

same as loadfilefolders but with permission checking

processAdminCommand() method
protected void processAdminCommand()
Source Code: app/controllers/FolderController.php#1291 (show)
protected function processAdminCommand()
{
    if(isset(
$_POST['command'], $_POST['id']) && $_POST['command']==='delete')
    {
        
$this->loadentity($_POST['id'])->delete();
        
// reload the current page to avoid duplicated delete actions
        
$this->refresh();
    }
}

Executes any command triggered on the admin page.

Copyright © 2008-2011 by Yii Software LLC
All Rights Reserved.