My Console Application Class Reference

RecordController

Package application.controllers.RecordController
Inheritance class RecordController » Controller » SBaseController » CController » CBaseController » CComponent
Views admin, annotate, create, createUTag, createmulti, createmultiUTag, edithold, editholdUTag, findFiles, findFiles2, findFiles2UTag, findFilesUTag, link, link2, list, mapMetadatas, mapMetadatasUTag, recordedit, recordview, show, showfolder, showfolder4c, showfolder4cUTag, showgroups, showread, showrecords, showupdate, update
Source Code app/controllers/RecordController.php
RecordController defines record 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'. RecordController
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
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

Protected Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
treeData Get tree data (old verson) RecordController

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. RecordController
actionAdmin() Manages all record models in a particular project/collection. RecordController
actionAnnotMov() RecordController
actionAnnotate() annotate relation image/video etc RecordController
actionCreate() Creates a new record. RecordController
actionCreateUTag() Creates a new record and link to the current tag. RecordController
actionCreatemulti() Create records from files RecordController
actionCreatemultiUTag() Creates records from files and link to the current tag. RecordController
actionDeleanota() Delete image annotation RecordController
actionDelete() Deletes a particular record model. RecordController
actionDeleteAllinHold() Batch delete record in holding RecordController
actionDeleteTag() Delete the links between category and record from record page, including the links between its subcategories and the record. RecordController
actionEdithold() Batch edit record in holding RecordController
actionEditholdUTag() Batch edit record in holding under tag RecordController
actionFindAllFiles() Search files function for creating records and linking files to records pages RecordController
actionGetanota() Get annotations to show on the annotation list RecordController
actionHold() Put record in holding for batch edit/delete RecordController
actionLink2() Link records to a record RecordController
actionList() Lists all models. RecordController
actionMakeCover() make the record as collection or set cover depends on type value RecordController
actionMapMetadatas() Map metadatas when create files from records RecordController
actionMapMetadatasUTag() Map metadatas when create files from records under tag (created records will be linked to tag) RecordController
actionMovAnnotDel() Delete movie annotation RecordController
actionRecordView() An action set up for record read only page RecordController
actionReloadTagcontent() Reload the category list on the record page after delete/add record from/to categories RecordController
actionSaveanota() Create or update image annotation RecordController
actionShow() Shows a particular record. RecordController
actionShowfolder() Shows a particular folder for selecting file to link. RecordController
actionShowfolder4c() Shows a particular folder for selecting file to create. RecordController
actionShowfolder4cUTag() Shows a particular folder for selecting file to create under tag. RecordController
actionShowgroups() Shows sets for selecting record to link. RecordController
actionShowimagetbn() Shows record image thumbnail (moved to fileController) RecordController
actionShowrecords() Shows records for selecting records to link. RecordController
actionUpdate() Updates a particular record model. RecordController
actionView() same action as show, create for view in gridview widget RecordController
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
copyMetadata() Copy filled in metadata only from one entity to the other (file to record) RecordController
copyMetadata2() Copy (filled in, controlled vocabulary) metadata from one entity to the other (file to record) according to metadata mapping RecordController
creatRecordfFile() Create records from files RecordController
creatRecordfFile2() Create records from files RecordController
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
deleteRecord() RecordController
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() RecordController
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
getDescendants() Get category descendant tag hierarchy models by category id RecordController
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
getMetadataTypes() Get project metadata types according to entity type RecordController
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
getPrjMetadataType() Get project metadata type according to entity type RecordController
getRecordPrjId() Get record project id according to record id RecordController
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() RecordController
hasEvent() Determines whether an event is defined. CComponent
hasEventHandler() Checks whether the named event has attached handlers. CComponent
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. RecordController
loadfilefolders() Get file, subfolder, file&subfolder models according to folder id RecordController
loadfilefoldersWP() same as loadfilefolders but with permission checking RecordController
loadfiles() Load file models according to its parent (folder) id RecordController
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
getChildTreeData() Get sub tree data (old version) RecordController
getTagAncestors() Get category ancestor tag models by category id RecordController
getTagRoots() Get category root tag models for project/collection RecordController
getTreeData() Get tree data (old verson) RecordController
link2File() Link record to file RecordController
link2Group() Link record to group/set (old version) RecordController
link2Project() Link record to project/collection RecordController
link2Tag() Link record to category RecordController
link2record() Link record to record RecordController
loadPageStates() Loads page states from a hidden input. CController
loadentitydata() Load metadata (filled in, controlled vocabulary and record link list) of the current record model and its metadata types RecordController
onUnauthorizedAccess() SBaseController
processAdminCommand() Executes any command triggered on the admin page. RecordController
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'.

treeData property read-only
protected void getTreeData(integer $id=NULL, integer $expandId1=NULL, integer $expandId2=NULL)

Get tree data (old verson)

Method Details

accessRules() method
public array accessRules()
{return} array access control rules
Source Code: app/controllers/RecordController.php#39 (show)
public function accessRules()
{
    
$user Yii::app()->user;
    if(
$user==null||$user->id==null)$this->redirect(array('site/redirectlogin'));    
    
$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('delete''admin'),
        
//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('makeCover''create''createUTag''createMulti''createMultiUTag''mapMetadatas''mapMetadatasUTag''update''link''link2''showfolder''showfolder4c''showfolder4cUTag''annotate','movAnnotDel'
            
'annotMov''getAnota''saveAnota''delAnota''deleteAllinHold''editHold''editHoldUTag''showupdate'),
        
//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
            
'actions'=>array('view','show''findAllFiles''showimagetbn''list''showGroups''showRecords''hold''getAnnot''showread''recordview'),
        
//check user has system admin or project admin access
            
'expression'=>'!Yii::app()->user->checkAccess("UserAdmin") && !'.($hasPrjRead).' && !'.($hasPrjWrite).' && !'.($hasPrjAdmin),

        )
    );
}

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

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

    
$criteria=new CDbCriteria;
    
$currentProject Yii::app()->getGlobalState('currentProject');
    
$criteria=new CDbCriteria;
    
$condition='(entityType.type=2)';
    
$condition=$condition.' AND relation.entity2='.$currentProject;
     
$condition=$condition.' AND relation.typeId='.relationType::IS_PART_OF;
     
$criteria->join "LEFT JOIN relation ON relation.entity1=t.id LEFT JOIN entityType ON entityType.id=t.typeId";
    
$criteria->addCondition($condition);
    
$criteria->condition $condition;
    
    
$model=new entity();
    
$model->unsetAttributes();  // clear any default values
    
if(isset($_GET['entity']))
    
$model->attributes=$_GET['entity'];
    
    
$models = new CActiveDataProvider('entity', array(
        
'criteria'=>$criteria,
    ));

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

Manages all record models in a particular project/collection.

actionAnnotMov() method
public void actionAnnotMov()
Source Code: app/controllers/RecordController.php#1258 (show)
public function actionAnnotMov(){
    
$new_annot $_POST['new_annot'];
    
$entity1 $_POST['entity1'];
    
$entity2 $_POST['entity2'];
    
$position $_POST['position'];
    
//$position = intval((int)$position/1000)*1000;
    
$anota = new movRepsAnnotation();
    
$data = array();
    
$anotaList "";
    
$anotaList "";$anotaList0 "add";
    if(
$new_annot&&$entity1&&$entity2&&$position){
        
$anota->entity1 $entity1;
        
$anota->entity2 $entity2;
        
$anota->text $new_annot;
        
$anota->position $position;
        if(isset(
$_POST['isaudio']))
            
$anota->isaudio $_POST['isaudio'];
        
$anota->save();
                
           
$data["myValue"] = "Annotation has been added.";
    }else{
        
        
$data["myValue"] = "Please play video and pause it at the point to be annotated and enter annotation text before pressing annotation button.";
        
    }
    if(
$entity1&&$entity2){
        
$criteria=new CDbCriteria;
        
$condition='(entity1='.entity1.' AND entity2='.$entity2.") order by id";

        
$criteria->condition $condition;
        
$movAnotas movRepsAnnotation::model()->findAll($criteria);
        
$anotaList "";
        foreach (
$movAnotas as $anota){

            
$anotaList=$anotaList'<a href="javascript:void(0)" onclick="javascript:jump('.$anota->position.')">position: '.$anota->position.': '.$anota->text.'</a> '.'<a href="javascript:void(0)" onclick=$("#movie_annotations_'.$entity1.'_'.$entity2.'").html("").load("index.php?r=record/MovAnnotDel&id='.$anota->id.'&entity1='.$entity1.'&entity2='.$entity2.'") >delete</a>'.'<br/>';
            
$anotaList0=$anotaList0.$anota->id." ";
        }
    }
    
//refresh annotation list
     
$data["anotaList"] = $anotaList;
    echo 
$data["myValue"].'<br/>';
    echo 
$anotaList;
    
/*echo '<script type="text/javascript">
            //<![CDATA[
            $test = document.getElementById("movie_annotations");
            alert($test.innerHTML);
            alert("'.$anotaList0.'");
             $("a").click(fn);
            
    //]]>
    </script>';*/
      

    
}

actionAnnotate() method
public void actionAnnotate()
Source Code: app/controllers/RecordController.php#1205 (show)
public function actionAnnotate(){
    
    
$this->render('annotate',array('relation'=>$this->loadrelation()));
}

annotate relation image/video etc

actionCreate() method
public void actionCreate()
Source Code: app/controllers/RecordController.php#204 (show)
public function actionCreate()
{
    
$criteria=new CDbCriteria;
    
$criteria->condition "type=2";
    
$criteria->order "t.iOrder";
    
$entityTypes entityType::model()->findAll($criteria);
    if(
$_GET['prjId']!=null)
        
Yii::app()->setGlobalState('currentProject'$_GET['prjId']);
    
$typeId entityType::MANMADE_OBJECT_TYPE;
    
$typeId = ($_GET['typeId']!=null) ? $_GET['typeId'] : $typeId;
    
$metadataTypes $this->getMetadataTypes($typeId);
    
$model=new entity;
    
//for save
    
if(isset($_POST['entity'])&&$_GET['typeId']==null)
    {
        
$model->attributes=$_POST['entity'];
        
$model->timeCreated=date("Y-m-d H-i-s"time());
        
$model->timeModified=date("Y-m-d H-i-s"time());
        
$newMetadatas $_POST['newMetadatas'];
        
$cFilled 1;
        
$index 0;
        if(
$newMetadatas!=null){
            
//fields marked with * compulsory have to be filled, otherwise reports error
            
foreach($newMetadatas as $typeId=>$value){
                
$type prjMetadataType::model()->findbyPk($typeId);
                
$typeName $type->name;
                if(
strpos($typeName'*')&&($value==null||trim($value)=='')){                    
                    
$cFilled 0;
                    
$model->addError('name'$typeName.' cannot be blank.');
                }else if(
strpos($typeName'*')){
                    if(
$index==0)
                        
$model->name $value;
                    
$index=1;
                }
            }
        }    
        
//compulsory fields are filled
        
if($cFilled)
            if(
$model->save()){
                
//$model->name = $model->entityType->id."_".$model->id;
                //$model->save();
                //$this->link2Group($model,Yii::app()->getGlobalState('currentSet'));
                
$this->link2Project($model,Yii::app()->getGlobalState('currentProject'));
                if(
$newMetadatas!=null){
                    foreach(
$newMetadatas as $typeId=>$value):
                        
                        
$metadataType prjMetadataType::model()->findbyPk($typeId);
                        if(
$metadataType->sourceType==metadataType::SOURCE_FILLEDIN){
                            
$metadata = new metadata;
                            
$metadata->typeId $typeId;
                            
$metadata->content $value;
                            
$metadata->entityId $model->id;
                            
$metadata->save();
                        }else if(
$metadataType->sourceType==metadataType::SOURCE_CVLIST){//for controlled vocabulary field metadata
                            
if($metadataType->isMultiple){
                                foreach(
$value as $cvListId){
                                    
$cvListRela = new cvListRela;
                                    
$cvListRela->entityId $model->id;
                                    
$cvListRela->cvListId $cvListId;
                                    
$cvListRela->metadataTypeId $metadataType->id;
                                    
$cvListRela->save();
                                }
                            }else{
                                
$cvListRela = new cvListRela;
                                
$cvListRela->entityId $model->id;
                                
$cvListRela->cvListId $value;
                                
$cvListRela->metadataTypeId $metadataType->id;
                                
$cvListRela->save();
                            }
                        }else if(
$metadataType->sourceType==metadataType::SOURCE_ENTITYLIST){//for record link list field metadata
                            
if($metadataType->isMultiple){
                                foreach(
$value as $entityListId){
                                    
$entityListRela = new entityListRela;
                                    
$entityListRela->entityId $model->id;
                                    
$entityListRela->entityListId $entityListId;
                                    
$entityListRela->metadataTypeId $metadataType->id;
                                    
$entityListRela->save();
                                }
                            }else{
                                
$entityListRela = new entityListRela;
                                
$entityListRela->entityId $model->id;
                                
$entityListRela->entityListId $value;
                                
$entityListRela->metadataTypeId $metadataType->id;
                                
$entityListRela->save();
                            }
                        }
                    endforeach;
                }
                
$this->redirect(array('show','id'=>$model->id));            
            }
    }
    
//for show create page
    
$this->render('create',array('model'=>$model,'entityTypes'=>$entityTypes'selectedType'=>$typeId'metadataTypes'=>$metadataTypes));
}

Creates a new record. If creation is successful, the browser will be redirected to the 'show' page.

actionCreateUTag() method
public void actionCreateUTag()
Source Code: app/controllers/RecordController.php#303 (show)
public function actionCreateUTag()
{
    
$criteria=new CDbCriteria;
    
$criteria->condition "type=2";
    
$criteria->order "t.iOrder";
    
$entityTypes entityType::model()->findAll($criteria);
    
    
$typeId entityType::MANMADE_OBJECT_TYPE;
    
$typeId = ($_GET['typeId']!=null) ? $_GET['typeId'] : $typeId;
    
$metadataTypes $this->getMetadataTypes($typeId);
    
$model=new entity;
    
//for save
    
if(isset($_POST['entity'])&&$_GET['typeId']==null&&$_GET['tagId']!=null)
    {
        
$model->attributes=$_POST['entity'];
        
$model->timeCreated=date("Y-m-d H-i-s"time());
        
$model->timeModified=date("Y-m-d H-i-s"time());
        
$newMetadatas $_POST['newMetadatas'];
        
$cFilled 1;
        
$index 0;
        if(
$newMetadatas!=null){
            
//fields marked with * compulsory have to be filled, otherwise reports error
            
foreach($newMetadatas as $typeId=>$value){
                
$type prjMetadataType::model()->findbyPk($typeId);
                
$typeName $type->name;
                if(
strpos($typeName'*')&&($value==null||trim($value)=='')){                    
                    
$cFilled 0;
                    
$model->addError('name'$typeName.' cannot be blank.');
                }else if(
strpos($typeName'*')){
                    if(
$index==0)
                        
$model->name $value;
                    
$index=1;
                }
            }
        }    
        
//compulsory fields are filled
        
if($cFilled)
            if(
$model->save()){
                
//$model->name = $model->entityType->id."_".$model->id;
                //$model->save();
                //$this->link2Group($model,Yii::app()->getGlobalState('currentSet'));
                
$this->link2Project($model,Yii::app()->getGlobalState('currentProject'));
                
$this->link2Tag($model,$_GET['tagId']);
                if(
$newMetadatas!=null){
                    foreach(
$newMetadatas as $typeId=>$value):
                        
                        
$metadataType prjMetadataType::model()->findbyPk($typeId);
                        if(
$metadataType->sourceType==metadataType::SOURCE_FILLEDIN){
                            
$metadata = new metadata;
                            
$metadata->typeId $typeId;
                            
$metadata->content $value;
                            
$metadata->entityId $model->id;
                            
$metadata->save();
                        }else if(
$metadataType->sourceType==metadataType::SOURCE_CVLIST){//for controlled vocabulary field metadata
                            
if($metadataType->isMultiple){
                                foreach(
$value as $cvListId){
                                    
$cvListRela = new cvListRela;
                                    
$cvListRela->entityId $model->id;
                                    
$cvListRela->cvListId $cvListId;
                                    
$cvListRela->metadataTypeId $metadataType->id;
                                    
$cvListRela->save();
                                }
                            }else{
                                
$cvListRela = new cvListRela;
                                
$cvListRela->entityId $model->id;
                                
$cvListRela->cvListId $value;
                                
$cvListRela->metadataTypeId $metadataType->id;
                                
$cvListRela->save();
                            }
                        }else if(
$metadataType->sourceType==metadataType::SOURCE_ENTITYLIST){//for record link list field metadata
                            
if($metadataType->isMultiple){
                                foreach(
$value as $entityListId){
                                    
$entityListRela = new entityListRela;
                                    
$entityListRela->entityId $model->id;
                                    
$entityListRela->entityListId $entityListId;
                                    
$entityListRela->metadataTypeId $metadataType->id;
                                    
$entityListRela->save();
                                }
                            }else{
                                
$entityListRela = new entityListRela;
                                
$entityListRela->entityId $model->id;
                                
$entityListRela->entityListId $value;
                                
$entityListRela->metadataTypeId $metadataType->id;
                                
$entityListRela->save();
                            }
                        }
                    endforeach;
                }
                
$this->redirect(array('show','id'=>$model->id));            
            }
    }
    
//for create page
    
$this->render('createUTag',array('tagId'=>$_GET['tagId'], 'model'=>$model,'entityTypes'=>$entityTypes'selectedType'=>$typeId'metadataTypes'=>$metadataTypes));
}

Creates a new record and link to the current tag. If creation is successful, the browser will be redirected to the 'show' page.

actionCreatemulti() method
public void actionCreatemulti()
Source Code: app/controllers/RecordController.php#430 (show)
public function actionCreatemulti(){
    if(
$_GET['prjId']!=null)
        
Yii::app()->setGlobalState('currentProject'$_GET['prjId']);
    
//for show create page
    
if(!isset($_POST['files'])){
        
/*$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))";
        
        $criteria=new CDbCriteria;
        $condition='t.typeId='.entityType::FOLDER_TYPE.' and relation1.typeId='.relationType::IS_PART_OF.'  AND NOT EXISTS '.$sql2;
        $criteria->condition = $condition;
        $criteria->order ="t.name";
        
        $pages=new CPagination(strval(count(entity::model()->with('relation1','relation1.entity2entity.relation1d')->together()->findAll($criteria))));
        $pages->pageSize=self::PAGE_SIZE;
        $pages->applyLimit($criteria);
        
        $models = entity::model()->with('relation1','relation1.entity2entity.relation1d')->together()->findAll($criteria);
        
        */
        //get assessable folders to create records from files based on user permissions
        
$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->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;
        
$criteria->distinct true;
        
$pages=new CPagination(entity::model()->count($criteria));
        
$pages->pageSize=self::PAGE_SIZE;
        
$pages->applyLimit($criteria);
        
        
$models entity::model()->findAll($criteria);
        
        
$this->render('createmulti',array(
            
'models'=>$models,
            
'pages'=>$pages,
        ));
        
    }else{
        
//for save 
        
$typeId entityType::IMAGE_OBJECT_TYPE;
        
$typeId = ($_GET['typeId']!=null) ? $_GET['typeId'] : $typeId;
        
$files $_POST['files'];

        foreach (
$files as $file){
                
$this->creatRecordfFile($file$typeIdnull);
            
        }
        
$this->redirect(array('collection/show','id'=>Yii::app()->getGlobalState('currentProject')));        
    }
}

Create records from files

actionCreatemultiUTag() method
public void actionCreatemultiUTag()
Source Code: app/controllers/RecordController.php#492 (show)
public function actionCreatemultiUTag(){
    
//for show create page
    
if(!isset($_POST['files'])){
        
/*$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))";
        
        $criteria=new CDbCriteria;
        $condition='t.typeId='.entityType::FOLDER_TYPE.' and relation1.typeId='.relationType::IS_PART_OF.'  AND NOT EXISTS '.$sql2;
        $criteria->condition = $condition;
        $criteria->order ="t.name";
        
        $pages=new CPagination(strval(count(entity::model()->with('relation1','relation1.entity2entity.relation1d')->together()->findAll($criteria))));
        $pages->pageSize=self::PAGE_SIZE;
        $pages->applyLimit($criteria);
        
        $models = entity::model()->with('relation1','relation1.entity2entity.relation1d')->together()->findAll($criteria);
        
        */
        
$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->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;
        
$criteria->distinct true;
        
$pages=new CPagination(entity::model()->count($criteria));
        
$pages->pageSize=self::PAGE_SIZE;
        
$pages->applyLimit($criteria);
        
        
$models entity::model()->findAll($criteria);
        
$tag tags::model()->findbyPK($_GET['tagId']);
        
$this->render('createmultiUTag',array(
            
'models'=>$models,
            
'pages'=>$pages,
            
'tag'=>$tag
        
));
        
    }else{
        
//for save
        
$typeId entityType::IMAGE_OBJECT_TYPE;
        
$typeId = ($_GET['typeId']!=null) ? $_GET['typeId'] : $typeId;
        
$files $_POST['files'];

        foreach (
$files as $file){
                
$this->creatRecordfFile($file$typeId$tag->id);
            
        }
        
$this->redirect(array('tags/tag','id'=>$tag->id));        
    }
}

Creates records from files and link to the current tag.

actionDeleanota() method
public true/false actionDeleanota()
{return} true/false
Source Code: app/controllers/RecordController.php#1344 (show)
public function actionDeleanota(){
    
    if(isset(
$_GET['id'])){
        
$anota imgRepsAnnotation::model()->findbyPk($_GET['id']);
        if(
$anota->delete())return ture;
        return 
false;            
    }
}

Delete image annotation

actionDelete() method
public void actionDelete()
Source Code: app/controllers/RecordController.php#922 (show)
public function actionDelete()
{
    if(
Yii::app()->request->isPostRequest)
    {
        
// we only allow deletion via POST request
        
$this->deleteRecord($this->loadentity($_GET['id'])->id);
        
$currentProject_id Yii::app()->getGlobalState('currentProject');
        
//unset($_SESSION['hold'][array_search($this->loadentity()->id, $_SESSION['hold'])]);
    
}
    else
        throw new 
CHttpException(400,'Invalid request. Please do not repeat this request again.');
}

Deletes a particular record model. If deletion is successful, the browser will be redirected to the 'list' page.

actionDeleteAllinHold() method
public void actionDeleteAllinHold()
Source Code: app/controllers/RecordController.php#1404 (show)
public function actionDeleteAllinHold(){
    if(
$_SESSION['hold']!=null&&sizeof($_SESSION['hold'])>0){
        foreach (
$_SESSION['hold'] as $id){
            
$this->deleteRecord($id);
            
//unset($_SESSION['hold'], $id);
                        
        
}
        
//$this->redirect(array('edithold', 'id'=>$_GET['id'], 'saved'=>true));
    
}
}

Batch delete record in holding

actionDeleteTag() method
public void actionDeleteTag()
Source Code: app/controllers/RecordController.php#1734 (show)
public function actionDeleteTag(){
    
$recordId $_GET["id"];
    
$tagId $_GET["tagId"];
    
//get subcategories
    
$descendants $this->getDescendants($tagId);
    
$desBracket "(";
    foreach(
$descendants as $des){
        if(
$desBracket!="("){
            
$desBracket.=",";
        }
        
$desBracket.=$des->descendantId;
    }
    
$desBracket .= ")";
     if(
$desBracket!="()"){
        
$criteria=new CDbCriteria;
        
$condition='t.tagId IN '.$desBracket.' and t.recordId='.$recordId;             
         
$criteria->condition $condition;
         
$tagsS tagsStatic::model()->findAll($criteria);
         foreach(
$tagsS as $tagS){
             
$tagS->delete();
         }
     }
    
$criteria=new CDbCriteria;
    
$condition='t.recordId='.$recordId;             
     
$criteria->condition $condition;
     
$tagsS tagsStatic::model()->findAll($criteria);
     
$tagsSAns = array();
     foreach(
$tagsS as $tags){
         
$tagsSAns[]=$this->getTagAncestors($tags->tagId);
     }
     
//get the category list on the record page
     
$tagContent "";
    foreach(
$tagsSAns as $tags){
        
$tagsString "";
        
$lastTagId;
        foreach(
$tags as $tag){
            if(
$tagsString != "")
                
$tagsString .= " > ";
            
//$tagsString .= $tag->name;
            
$tagsString .= CHtml::link($tag->name,array('tags/tag&id='.$tag->id));
            
$lastTagId$tag->id;
        }
        
$imghtml =  CHtml::image(Yii::app()->baseUrl.'/images/icon/delete.png''Remove record from this category', array('title'=>'Remove record from this category''width'=>'10px''height'=>'10px'));
        
$tagContent .= '<span class="round">'.$tagsString." ".CHtml::ajaxLink($imghtml,$this->createUrl('record/deleteTag', array('id'=>$model->id'tagId'=>$lastTagId)),array(      
            
'update'=>'#tagContent'
            
),array('id'=>'delTag_'.$lastTagId'confirm'=>"Are you sure you want to remove this record from this category?")).'</span>&nbsp;';
            
        
$tagContent .= ' ';
    
    }
    echo 
'Categories: '.$tagContent'<span class="round">Drag to category '
    
.CHtml::image(Yii::app()->baseUrl.'/images/default/interface/add10.png''Drag icon to category', array('title'=>'Drag icon to category'
    
'class'=>'jstree-draggable''id'=>$recordId'width'=>'10px''height'=>'10px'
    
)).'</span>';
     
//$this->renderPartialWithHisOwnClientScript('_tagNav', array('tag'=>$tag, 'recordId'=>$recordId, 'tagsSAns'=>$tagsSAns));
    
}

Delete the links between category and record from record page, including the links between its subcategories and the record.

actionEdithold() method
public void actionEdithold()
Source Code: app/controllers/RecordController.php#1417 (show)
public function actionEdithold(){

    if(
$_GET['prjId']!=null)Yii::app()->setGlobalState('currentProject'$_GET['prjId']);
    
    
$project_id Yii::app()->getGlobalState('currentProject');
    
$holdRecordsModel = array();
    
session_start(); 
    
//delete all holding that doesn't belongs to this project
    
    
if($_SESSION['hold']!=null&&sizeof($_SESSION['hold'])>0){
        
$ids "(";
        foreach (
$_SESSION['hold'] as $id){
            
//get only record in this project
            
$recordPrjId $this->getRecordPrjId($id);
            if(
$recordPrjId==$project_id)
                
$ids=$ids.$id.",";
            else     
                unset(
$_SESSION['hold'], $id);
        }
        
$ids=$ids.'-1)';
        
$criteria=new CDbCriteria;
        
$condition='entityType.type=2';
        
$condition=$condition.' AND t.id in '.$ids;
        
$criteria->condition $condition;
        
//get holding record models
        
$holdRecordsModel entity::model()->with('entityType')->together()->findAll($criteria);
        
$pages=new CPagination(entity::model()->with('entityType')->together()->count($criteria));
        
$pages->pageSize=self::PAGE_SIZE;
        
$pages->applyLimit($criteria);
        
        
$criteriaType=new CDbCriteria;
        
$condition='entity.id in '.$ids;
        
$criteriaType->condition $condition;
        
$entityTypesModel entityType::model()->with('entity')->together()->findAll($criteriaType);
        
        
//user hasn't selected a record type to edit
        
if($_POST['editEntityType']!=null&&$_POST['selectedTypes']==null){
            
$editEntityType $_POST['editEntityType'];
            
$metadataTypes $this->getPrjMetadataType($editEntityType);            
            
$this->render('edithold',array('holdRecordsModel'=>$holdRecordsModel'entityTypesModel'=>$entityTypesModel'pages'=>$pages'editEntityType'=>$editEntityType'metadataTypes'=>$metadataTypes,
            
'treeData'=>1));
            return;
        }else if(
$_POST['editEntityType']!=null&&$_POST['selectedTypes']!=null){//user has selected a record type to edit, save the change
            
$editEntityType $_POST['editEntityType'];
            
$selectedTypes $_POST['selectedTypes'];
            
$newMetadatas $_POST['newMetadatas'];
            
$newInputs $_POST['newinput'];
            foreach(
$selectedTypes as $typeId=>$selected){
                if(
$selected==1){
                    
$value $newMetadatas[$typeId];
                    if(
$value!=null&&trim($value)!=''&&$_SESSION['hold']!=null){
                        foreach (
$_SESSION['hold'] as $editRecordId){
                            
$metadataType prjMetadataType::model()->findbyPk($typeId);
                            
$model entity::model()->findbyPk($editRecordId);
                            
                            if(
$metadataType->sourceType==metadataType::SOURCE_FILLEDIN){ //save filled in field metadata
                                
$existMetadata metadata::model()->findByAttributes(array('typeId'=>$typeId,'entityId'=>$editRecordId));    
                                if(
$existMetadata!=null ){
                                    
$existMetadata->content $value;
                                    
$existMetadata->save();
                                }else{
                                    
$metadata = new metadata;
                                    
$metadata->typeId $typeId;
                                    
$metadata->content $value;
                                    
$metadata->entityId $editRecordId;
                                    
$metadata->save();
                                }
                            }else if(
$metadataType->sourceType==metadataType::SOURCE_CVLIST){//save controlled vocabulary list field metadata
                                
$oldCvListRelas cvListRela::model()->findAllByAttributes(array('metadataTypeId'=>$typeId,'entityId'=>$editRecordId)); //$model->cvListRela;
                                
if($oldCvListRelas!=null)
                                    foreach(
$oldCvListRelas as $rela)
                                        
$rela->delete();
                                if(
$metadataType->isMultiple){
                                    foreach(
$value as $cvListId){
                                        
$cvListRela = new cvListRela;
                                        
$cvListRela->entityId $model->id;
                                        
$cvListRela->cvListId $cvListId;
                                        
$cvListRela->metadataTypeId $metadataType->id;
                                        
$cvListRela->save();
                                    }
                                }else{
                                    
$cvListRela = new cvListRela;
                                    
$cvListRela->entityId $model->id;
                                    
$cvListRela->cvListId $value;
                                    
$cvListRela->metadataTypeId $metadataType->id;
                                    
$cvListRela->save();
                                }
                            }else if(
$metadataType->sourceType==metadataType::SOURCE_ENTITYLIST){//save record link list field metadata
                                
$oldEntityListRelas entityListRela::model()->findAllByAttributes(array('metadataTypeId'=>$typeId,'entityId'=>$editRecordId)); //$model->entityListRela;
                                
if($oldEntityListRelas!=null)
                                    foreach(
$oldEntityListRelas as $rela)
                                        
$rela->delete();
                                if(
$metadataType->isMultiple){
                                    foreach(
$value as $entityListId){
                                        
$entityListRela = new entityListRela;
                                        
$entityListRela->entityId $model->id;
                                        
$entityListRela->entityListId $entityListId;
                                        
$entityListRela->metadataTypeId $metadataType->id;
                                        
$entityListRela->save();
                                    }
                                }else{
                                    
$entityListRela = new entityListRela;
                                    
$entityListRela->entityId $model->id;
                                    
$entityListRela->entityListId $value;
                                    
$entityListRela->metadataTypeId $metadataType->id;
                                    
$entityListRela->save();
                                }
                            }                        
                        }
                    }
                    
$value $newInputs[$typeId]; //add controlled vocabulary list item if it is not fixed
                    
if($value!=null&&trim($value)!=''){                        
                        
$cvType $_POST['newinputCvType'][$typeId];
                        
$metadataType prjMetadataType::model()->findbyPk($typeId);
                        
                        if(
$cvType!=null){
                            
$existed false;
                            
$criteria=new CDbCriteria;
                            
$condition='typeId='.$cvType;
                            
$criteria->condition $condition;
                            
$cvTypeLists=cvList::model()->findAll($criteria);
                            
                            foreach(
$cvTypeLists as $list){
                                if(
$list->name==$value)
                                    
$existed=true;
                            }
                            
                            if(!
$existed&&$metadataType->cvListType->fixed!=1){
                                
$cvList = new cvList;
                                
$cvList->name $value;
                                
$cvList->typeId $cvType;
                                
$cvList->save();
                                foreach (
$_SESSION['hold'] as $editRecordId){
                                    
$model entity::model()->findbyPk($editRecordId);
                                    
$cvListRela = new cvListRela;
                                    
$cvListRela->entityId $model->id;
                                    
$cvListRela->cvListId $cvList->id;
                                    
$cvListRela->metadataTypeId $typeId;
                                    
$cvListRela->save();
                                }
                            }
                        }
                    }
                }
            }
            
$metadataTypes $this->getPrjMetadataType($_POST['editEntityType']);
            
//show batch edit page
            
$this->render('edithold',array('saved'=>true'holdRecordsModel'=>$holdRecordsModel'entityTypesModel'=>$entityTypesModel'pages'=>$pages'editEntityType'=>$editEntityType,'metadataTypes'=>$metadataTypes,
            
'treeData'=>1));
            return;
        }
        
    }
    
//get category roots
    
$roots $this->getTagRoots($project_id);
    
    
$this->render('edithold',array('holdRecordsModel'=>$holdRecordsModel'entityTypesModel'=>$entityTypesModel'pages'=>$pages,'roots'=>$roots,
        
'treeData'=>1));
}

Batch edit record in holding

actionEditholdUTag() method
public void actionEditholdUTag()
Source Code: app/controllers/RecordController.php#1579 (show)
public function actionEditholdUTag(){
    
$tag tags::model()->findbyPK($_GET['tagId']);
    if(
$_GET['prjId']!=null)Yii::app()->setGlobalState('currentProject'$_GET['prjId']);
    
$project_id Yii::app()->getGlobalState('currentProject');
    
$holdRecordsModel = array();
    
session_start(); 
    
//delete all holding that doesn't belongs to this project
    
    
if($_SESSION['hold']!=null&&sizeof($_SESSION['hold'])>0){
        
$ids "(";
        foreach (
$_SESSION['hold'] as $id){
            
$recordPrjId $this->getRecordPrjId($id);
            if(
$recordPrjId==$project_id)
                
$ids=$ids.$id.",";
            else     
                unset(
$_SESSION['hold'], $id);
        }
        
$ids=$ids.'-1)';
        
$criteria=new CDbCriteria;
        
$condition='entityType.type=2';
        
$condition=$condition.' AND t.id in '.$ids;
        
$criteria->condition $condition;
        
$holdRecordsModel entity::model()->with('entityType')->together()->findAll($criteria);
        
$pages=new CPagination(entity::model()->with('entityType')->together()->count($criteria));
        
$pages->pageSize=self::PAGE_SIZE;
        
$pages->applyLimit($criteria);
        
        
$criteriaType=new CDbCriteria;
        
$condition='entity.id in '.$ids;
        
$criteriaType->condition $condition;
        
$entityTypesModel entityType::model()->with('entity')->together()->findAll($criteriaType);
        
//user hasn't selected a record type to edit
        
if($_POST['editEntityType']!=null&&$_POST['selectedTypes']==null){
            
$editEntityType $_POST['editEntityType'];
            
$metadataTypes $this->getPrjMetadataType($editEntityType);            
            
$this->render('editholdUTag',array('tag'=>$tag,'holdRecordsModel'=>$holdRecordsModel'entityTypesModel'=>$entityTypesModel'pages'=>$pages'editEntityType'=>$editEntityType'metadataTypes'=>$metadataTypes,
            
'treeData'=>1));
            return;
        }else if(
$_POST['editEntityType']!=null&&$_POST['selectedTypes']!=null){//user has selected a record type to edit, save the change
            
$editEntityType $_POST['editEntityType'];
            
$selectedTypes $_POST['selectedTypes'];
            
$newMetadatas $_POST['newMetadatas'];
            
$newInputs $_POST['newinput'];
            foreach(
$selectedTypes as $typeId=>$selected){
                if(
$selected==1){
                    
$value $newMetadatas[$typeId];
                    if(
$value!=null&&trim($value)!=''&&$_SESSION['hold']!=null){
                        foreach (
$_SESSION['hold'] as $editRecordId){
                            
$metadataType prjMetadataType::model()->findbyPk($typeId);
                            
$model entity::model()->findbyPk($editRecordId);
                            
                            if(
$metadataType->sourceType==metadataType::SOURCE_FILLEDIN){ //save filled in field metadata
                                
$existMetadata metadata::model()->findByAttributes(array('typeId'=>$typeId,'entityId'=>$editRecordId));    
                                if(
$existMetadata!=null ){
                                    
$existMetadata->content $value;
                                    
$existMetadata->save();
                                }else{
                                    
$metadata = new metadata;
                                    
$metadata->typeId $typeId;
                                    
$metadata->content $value;
                                    
$metadata->entityId $editRecordId;
                                    
$metadata->save();
                                }
                            }else if(
$metadataType->sourceType==metadataType::SOURCE_CVLIST){//save controlled vocabulary list field metadata
                                
$oldCvListRelas cvListRela::model()->findAllByAttributes(array('metadataTypeId'=>$typeId,'entityId'=>$editRecordId)); //$model->cvListRela;
                                
if($oldCvListRelas!=null)
                                    foreach(
$oldCvListRelas as $rela)
                                        
$rela->delete();
                                if(
$metadataType->isMultiple){
                                    foreach(
$value as $cvListId){
                                        
$cvListRela = new cvListRela;
                                        
$cvListRela->entityId $model->id;
                                        
$cvListRela->cvListId $cvListId;
                                        
$cvListRela->metadataTypeId $metadataType->id;
                                        
$cvListRela->save();
                                    }
                                }else{
                                    
$cvListRela = new cvListRela;
                                    
$cvListRela->entityId $model->id;
                                    
$cvListRela->cvListId $value;
                                    
$cvListRela->metadataTypeId $metadataType->id;
                                    
$cvListRela->save();
                                }
                            }else if(
$metadataType->sourceType==metadataType::SOURCE_ENTITYLIST){//save record link list field metadata
                                
$oldEntityListRelas entityListRela::model()->findAllByAttributes(array('metadataTypeId'=>$typeId,'entityId'=>$editRecordId)); //$model->entityListRela;
                                
if($oldEntityListRelas!=null)
                                    foreach(
$oldEntityListRelas as $rela)
                                        
$rela->delete();
                                if(
$metadataType->isMultiple){
                                    foreach(
$value as $entityListId){
                                        
$entityListRela = new entityListRela;
                                        
$entityListRela->entityId $model->id;
                                        
$entityListRela->entityListId $entityListId;
                                        
$entityListRela->metadataTypeId $metadataType->id;
                                        
$entityListRela->save();
                                    }
                                }else{
                                    
$entityListRela = new entityListRela;
                                    
$entityListRela->entityId $model->id;
                                    
$entityListRela->entityListId $value;
                                    
$entityListRela->metadataTypeId $metadataType->id;
                                    
$entityListRela->save();
                                }
                            }                        
                        }
                    }
                    
$value $newInputs[$typeId];
                    if(
$value!=null&&trim($value)!=''){        //add controlled vocabulary list item if it is not fixed                
                        
$cvType $_POST['newinputCvType'][$typeId];
                        
$metadataType prjMetadataType::model()->findbyPk($typeId);
                        
                        if(
$cvType!=null){
                            
$existed false;
                            
$criteria=new CDbCriteria;
                            
$condition='typeId='.$cvType;
                            
$criteria->condition $condition;
                            
$cvTypeLists=cvList::model()->findAll($criteria);
                            
                            foreach(
$cvTypeLists as $list){
                                if(
$list->name==$value)
                                    
$existed=true;
                            }
                            
                            if(!
$existed&&$metadataType->cvListType->fixed!=1){
                                
$cvList = new cvList;
                                
$cvList->name $value;
                                
$cvList->typeId $cvType;
                                
$cvList->save();
                                foreach (
$_SESSION['hold'] as $editRecordId){
                                    
$model entity::model()->findbyPk($editRecordId);
                                    
$cvListRela = new cvListRela;
                                    
$cvListRela->entityId $model->id;
                                    
$cvListRela->cvListId $cvList->id;
                                    
$cvListRela->metadataTypeId $typeId;
                                    
$cvListRela->save();
                                }
                            }
                        }
                    }
                }
            }
            
$metadataTypes $this->getPrjMetadataType($_POST['editEntityType']);
            
$this->render('editholdUTag',array('tag'=>$tag'saved'=>true'holdRecordsModel'=>$holdRecordsModel'entityTypesModel'=>$entityTypesModel'pages'=>$pages'editEntityType'=>$editEntityType,'metadataTypes'=>$metadataTypes,
            
'treeData'=>1));
            return;
        }
        
    }
    
$roots $this->getTagRoots($project_id);
    
$this->render('editholdUTag',array('tag'=>$tag,'holdRecordsModel'=>$holdRecordsModel'entityTypesModel'=>$entityTypesModel'pages'=>$pages'roots'=>$roots,
        
'treeData'=>1));
}

Batch edit record in holding under tag

actionFindAllFiles() method
public void actionFindAllFiles()
Source Code: app/controllers/RecordController.php#551 (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'] ;
    if(isset(
$_POST['requestPage'])||isset($_GET['requestPage']))
        
$requestPage = ($_POST['requestPage']!=null) ? $_POST['requestPage'] : $_GET['requestPage'] ;
    
//search keyword and return results based on user permissions
    
$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'requestPage'=>$requestPage);
    
$pages->pageSize=self::PAGE_SIZE;
    
$pages->applyLimit($criteria);
    
$models entity::model()->findAll($criteria);
    
    
$criteria=new CDbCriteria;
    
$criteria->condition "type=2";
    
$criteria->order "t.iOrder";
    
$entityTypes entityType::model()->findAll($criteria);
    
$tag tags::model()->findbyPK($_GET['tagId']);
    
//show pages according to requesting page
    
if($_POST["requestPage"]=="createMultiUTag"||$_GET["requestPage"]=="createMultiUTag")
        
$this->render('findFilesUTag',array(
            
'models'=>$models,
            
'pages'=>$pages,
            
'entityTypes'=>$entityTypes,
            
'keyword'=>$keyword,
            
'tag'=>$tag
        
));
    else if(
$_POST["requestPage"]=="linkUTag"||$_GET["requestPage"]=="linkUTag"){
        
$this->render('findFiles2UTag',array(
            
'models'=>$models,
            
'pages'=>$pages,
            
'entityTypes'=>$entityTypes,
            
'record'=>$_POST['record'],
            
'keyword'=>$keyword,
            
'tag'=>$tag
        
));
    }
    else if(
$_POST["requestPage"]=="createMulti"||$_GET["requestPage"]=="createMulti")
        
$this->render('findFiles',array(
            
'models'=>$models,
            
'pages'=>$pages,
            
'entityTypes'=>$entityTypes,
            
'keyword'=>$keyword,
        ));
    else if(
$_POST["requestPage"]=="link"||$_GET["requestPage"]=="link"){
        
$this->render('findFiles2',array(
            
'models'=>$models,
            
'pages'=>$pages,
            
'entityTypes'=>$entityTypes,
            
'record'=>$_POST['record'],
            
'keyword'=>$keyword,
        ));
    }

}

Search files function for creating records and linking files to records pages

actionGetanota() method
public void actionGetanota()
Source Code: app/controllers/RecordController.php#1356 (show)
public function actionGetanota(){
    if(isset(
$_GET['entity1'])&&isset($_GET['entity2'])){
        
$entity2 substr($_GET['entity2'], 0strpos($_GET['entity2'],"?"));
        
$criteria=new CDbCriteria;
        
$condition='(entity1='.$_GET['entity1'].' AND entity2='.$entity2.")";

        
$criteria->condition $condition;
        
$imgAnotas imgRepsAnnotation::model()->findAll($criteria);
        
$json "[";
        foreach (
$imgAnotas as $anota){
            if(
$json!="[")
                
$json $json.',';
            
$txt nl2br($anota->text);//str_replace("<br/>", "\n", $anota->text);
            
$json$json.'{ "top": "'.$anota->top.'", "left": "'.$anota->left.'", "width": "'.$anota->width.'", "height": "'.$anota->height.'", "text": "'.$txt.'", "id": "'.$anota->id.'", "editable": true }';
        }
        
$json$json."]";
        print 
$json;
    }else
        print 
"[]";
}

Get annotations to show on the annotation list

actionHold() method
public void actionHold()
Source Code: app/controllers/RecordController.php#1379 (show)
public function actionHold(){
    if(isset(
$_GET['id'])){
        
$id $_GET['id'];
        
session_start(); 
        if(
$_SESSION['hold']!=null&&sizeof($_SESSION['hold'])>0){
            
//find id delete else add it to array
            
if(array_search($id$_SESSION['hold'])!==false){
                unset(
$_SESSION['hold'][array_search($id$_SESSION['hold'])]);
            }else
                
$_SESSION['hold'][]=$id;
        }else
            
$_SESSION['hold'] = array($id);
    }
    if(
$_SESSION['hold']!=null&&sizeof($_SESSION['hold'])>0){
        foreach(
$_SESSION['hold'] as $hold){
            print 
$hold;
            
        }
    }

    
}

Put record in holding for batch edit/delete

public void actionLink()
Source Code: app/controllers/RecordController.php#959 (show)
public function actionLink()
{    
//show folders/files according to user permissions
    
if(!isset($_POST['linkfile'])){
        
/*$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))";
        
        $criteria=new CDbCriteria;
        $condition='t.typeId='.entityType::FOLDER_TYPE.' and relation1.typeId='.relationType::IS_PART_OF.'  AND NOT EXISTS '.$sql2;
        $criteria->condition = $condition;
        $criteria->order ="t.name";
        
        $pages=new CPagination(strval(count(entity::model()->with('relation1','relation1.entity2entity.relation1d')->together()->findAll($criteria))));
        $pages->pageSize=self::PAGE_SIZE;
        $pages->applyLimit($criteria);
        
        $models = entity::model()->with('relation1','relation1.entity2entity.relation1d')->together()->findAll($criteria);
*/
        
$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->select = array("t.*");
        
$criteria->join "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(strval(count(entity::model()->with('relation1','relation1.entity2entity.relation1d')->together()->findAll($criteria))));
        
$pages->pageSize=self::PAGE_SIZE;
        
$pages->applyLimit($criteria);
        
        
$models entity::model()->with('relation1','relation1.entity2entity.relation1d')->together()->findAll($criteria);

        if(
$_GET['id']!=NULL){
            
$recordId $_GET['id'];
            
$this->render('link',array(
                
'models'=>$models,
                
'pages'=>$pages,
                
'record'=>$recordId,
            ));
        }
    }else{
        
//save links
        
$linkfiles $_POST['linkfile'];
        
$record $_POST['record'];
        foreach (
$linkfiles as $linkfile){
            if(
$record!=null){
                
$this->link2file($record$linkfile);
                
$metadatas $this->loadentitydata($record);                    
    
            }else
                throw new 
CHttpException(404,'The requested page does not exist.');
        }
        
$this->redirect(array('show','id'=>$record));            
    }
}

Link files to a record

actionLink2() method
public void actionLink2()
Source Code: app/controllers/RecordController.php#1022 (show)
public function actionLink2()
{
    
$form = new RelationForm();
    
//show records
    
if(!isset($_POST['linkrecord'])){
        
$criteria=new CDbCriteria;
        
$condition='typeId='.entityType::PROJECT_TYPE;
        
$criteria->condition $condition;
        
$pages=new CPagination(entity::model()->count($criteria));
        
$pages->pageSize=self::PAGE_SIZE;
        
$pages->applyLimit($criteria);

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

        if(
$_GET['id']!=NULL){
            
$recordId $_GET['id'];
            
$this->render('link2',array(
                
'models'=>$models,
                
'pages'=>$pages,
                
'record'=>$recordId,
            ));
        }
    }else{
        
//save links
        
$linkrecords $_POST['linkrecord'];
        
$record $_POST['record'];
        if(isset(
$_POST['RelationForm'])){
            
$form->attributes=$_POST['RelationForm'];
            if(
$form->validate())
            {
                
$name $form->name;
                
$content $form->content;
                foreach (
$linkrecords as $linkrecord){
                    if(
$record!=null){
                        
$this->link2record($record$linkrecord$name$content);
                        
                    }else
                        throw new 
CHttpException(404,'The requested page does not exist.');
                }
                
$metadatas $this->loadentitydata($record);
                
$this->redirect(array('show','id'=>$record));            
            }
        }
    }
}

Link records to a record

actionList() method
public void actionList()
Source Code: app/controllers/RecordController.php#938 (show)
public function actionList()
{
    
$criteria=new CDbCriteria;
    
//only show project space related record types
    
$condition='(entityType=2)';
    
$criteria->condition $condition;
    
$pages=new CPagination(entity::model()->count($criteria));
    
$pages->pageSize=self::PAGE_SIZE;
    
$pages->applyLimit($criteria);

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

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

Lists all models.

actionMakeCover() method
public void actionMakeCover()
Source Code: app/controllers/RecordController.php#177 (show)
public function actionMakeCover()
{
    if(isset(
$_GET['type'])&&isset($_GET['id'])){
        if(
$_GET['type']=="col"){
            
$colSetId Yii::app()->getGlobalState('currentProject');        
        }else if(
$_GET['type']=="set"){
            
$colSetId Yii::app()->getGlobalState('currentSet');                
        }
        
$criteria=new CDbCriteria;
         
$condition='t.colSetId='.$colSetId;             
         
$criteria->condition $condition;
         
$covers=cover::model()->findAll($criteria);
         foreach(
$covers as $cover){
             
$cover->delete();
         }
         
        
$cover = new cover;
        
$cover->colSetId $colSetId;
        
$cover->recordId $_GET['id'];
        
$cover->save();
    }
    
$this->actionShow();
}

make the record as collection or set cover depends on type value

actionMapMetadatas() method
public void actionMapMetadatas()
Source Code: app/controllers/RecordController.php#644 (show)
public function actionMapMetadatas(){
    if(isset(
$_POST['files'])){
        
//for showing mapping page
        
$files $_POST['files'];
        
$typeId $_POST['entity']['typeId'];
        
$fileTypeModels = array();
        foreach (
$files as $fileId){
            
$file=entity::model()->findbyPk($fileId);
            
$fileTypeModels[$file->typeId][] = $file;
        }
        
$criteria=new CDbCriteria;
        
$currentProject_id Yii::app()->getGlobalState('currentProject');
        
$condition='entityType='.$typeId.' and prjId='.$currentProject_id;
        
$criteria->condition $condition;
        
$criteria->order "id"
        
$models=prjMetadataType::model()->findAll($criteria);
        
        
$this->render('mapMetadatas', array('files'=>$files'typeId'=>$typeId'models'=>$models'fileTypeModels'=>$fileTypeModels)); 
    }else if(isset(
$_POST['typeId'])&&isset($_POST['entityTypes'])){
        
//for create records from mapping
        
$entityTypes explode("^",$_POST['entityTypes']);
        foreach(
$entityTypes as $entityType){
            if(
trim($entityType!="")){
                
//print $entityType.'<br/>';
                //print count($_POST['list'.$entityType.'1'])."<br/>";
                
$typeId $_POST['typeId'];
                
$files $_POST['file'.$entityType];
                
//print "files:".count($files).'<br/>';
                
$recordMetadatas explode("listItem".$entityType."1[]="str_replace('&','',$_POST['list'.$entityType.'1']));
                
$fileMetadatas explode("listItem".$entityType."2[]="str_replace('&','',$_POST['list'.$entityType.'2']));
                
//foreach($recordMetadatas as $data)
                //    print "file:".$data." ";
                //print "<br/>";
                
foreach($files as $file){//print $file;
                    
$this->creatRecordfFile2($file$typeId$recordMetadatas$fileMetadatasnull);
                }
            }
        }
        
$this->redirect(array('collection/show','id'=>Yii::app()->getGlobalState('currentProject')));        
    }
}

Map metadatas when create files from records

actionMapMetadatasUTag() method
public void actionMapMetadatasUTag()
Source Code: app/controllers/RecordController.php#688 (show)
public function actionMapMetadatasUTag(){
    
//for showing mapping page
    
if(isset($_POST['files'])){
        
$files $_POST['files'];
        
$typeId $_POST['entity']['typeId'];
        
$fileTypeModels = array();
        foreach (
$files as $fileId){
            
$file=entity::model()->findbyPk($fileId);
            
$fileTypeModels[$file->typeId][] = $file;
        }
        
$criteria=new CDbCriteria;
        
$currentProject_id Yii::app()->getGlobalState('currentProject');
        
$condition='entityType='.$typeId.' and prjId='.$currentProject_id;
        
$criteria->condition $condition;
        
$criteria->order "id"
        
$models=prjMetadataType::model()->findAll($criteria);
        
$tag tags::model()->findbyPK($_GET['tagId']);
        
        
$this->render('mapMetadatasUTag', array('tag'=>$tag'files'=>$files'typeId'=>$typeId'models'=>$models'fileTypeModels'=>$fileTypeModels)); 
    }else if(isset(
$_POST['typeId'])&&isset($_POST['entityTypes'])){
        
//for create records from mapping and link to tag 
        
$tag tags::model()->findbyPK($_GET['tagId']);
        
$entityTypes explode("^",$_POST['entityTypes']);
        foreach(
$entityTypes as $entityType){
            if(
trim($entityType!="")){
                
//print $entityType.'<br/>';
                //print count($_POST['list'.$entityType.'1'])."<br/>";
                
$typeId $_POST['typeId'];
                
$files $_POST['file'.$entityType];
                
//print "files:".count($files).'<br/>';
                
$recordMetadatas explode("listItem".$entityType."1[]="str_replace('&','',$_POST['list'.$entityType.'1']));
                
$fileMetadatas explode("listItem".$entityType."2[]="str_replace('&','',$_POST['list'.$entityType.'2']));
                
//foreach($recordMetadatas as $data)
                //    print "file:".$data." ";
                //print "<br/>";
                
foreach($files as $file){//print $file;
                    
$this->creatRecordfFile2($file$typeId$recordMetadatas$fileMetadatas$tag->id);
                }
            }
        }
        
$this->redirect(array('tags/tag','id'=>$tag->id));        
    }
}

Map metadatas when create files from records under tag (created records will be linked to tag)

actionMovAnnotDel() method
public void actionMovAnnotDel()
Source Code: app/controllers/RecordController.php#1213 (show)
public function actionMovAnnotDel(){
    
$id $_GET['id'];
    
$entity1 $_GET['entity1'];
    
$entity2 $_GET['entity2'];
    
$data = array();
    
$anotaList "";$anotaList0 "del";
    if(
$id){
        
$annot_model movRepsAnnotation::model()->findbyPk($id);
        if(
$annot_model!=null){
            
$annot_model->delete();
            
$data["myValue"] = "Annotation has been deleted.";
        }else
            
$data["myValue"] = "Problem deleting annotation.";
    }else
        
$data["myValue"] = "Problem deleting annotation.";
        
    if(
$entity1&&$entity2){
        
$criteria=new CDbCriteria;
        
$condition='(entity1='.entity1.' AND entity2='.$entity2.") order by id";

        
$criteria->condition $condition;
        
$movAnotas movRepsAnnotation::model()->findAll($criteria);
        
$anotaList "";
        foreach (
$movAnotas as $anota){

            
$anotaList=$anotaList'<a href="javascript:void(0)" onclick="javascript:jump('.$anota->position.')">'.$anota->id.":".$anota->position.': '.$anota->text.'</a> '.'<a href="javascript:void(0)" onclick=$("#movie_annotations_'.$entity1.'_'.$entity2.'").html("").load("index.php?r=record/MovAnnotDel&id='.$anota->id.'&entity1='.$entity1.'&entity2='.$entity2.'") >delete</a>'.'<br/>';
            
$anotaList0=$anotaList0.$anota->id." ";
        }
    }
    
//refresh annoation list
     
$data["anotaList"] = $anotaList;
    echo 
$data["myValue"].'<br/>';
    echo 
$anotaList;  
     
/*echo '<script type="text/javascript">
            //<![CDATA[
            $test = document.getElementById("movie_annotations");
            alert($test.innerHTML);
            alert("'.$anotaList0.'");
           $("a").click(fn);
            

            //]]>
    </script>';*/
}

Delete movie annotation

actionRecordView() method
public void actionRecordView()
Source Code: app/controllers/RecordController.php#125 (show)
public function actionRecordView()
{
    
$currentProject_id Yii::app()->getGlobalState('currentProject');

    
$currentProject entity::model()->findbyPk($currentProject_id);
    

    
$model $this->loadentity();
    
    
$criteria=new CDbCriteria;
    
$condition='t.type=2';
    
$criteria->condition $condition;
    
$criteria->order ="t.id";            
    
$typemodels entityType::model()->findAll($criteria);
    foreach(
$typemodels as $typemodel){
        
$types[$typemodel->id]=$typemodel->name;
    }
        
    
$metadatas $this->loadentitydata();
    
$user Yii::app()->user;
    if(
$user==null||$user->id==null)$this->redirect(array('site/redirectlogin'));    
    
$hasPrjAdmin $this->hasAccess($userroleAccess::ADMIN);
    
$hasPrjWrite $this->hasAccess($userroleAccess::WRITE);
    
$hasPrjRead $this->hasAccess($userroleAccess::READ);
    
    
$projectId Yii::app()->getGlobalState('currentProject');
    
$roots $this->getTagRoots($projectId);
    if(
$roots==null)$roots=1;
    
    
$criteria=new CDbCriteria;
    
$condition='t.recordId='.$model->id;             
     
$criteria->condition $condition;
     
$tagsS tagsStatic::model()->findAll($criteria);
     
$tagsSAns = array();
     foreach(
$tagsS as $tags){
         
$tagsSAns[]=$this->getTagAncestors($tags->tagId);
     }

        
$this->render('recordview',array('types'=>$types'model'=>$metadatas[0], 'currentProject'=>$currentProject'metadatas'=>$metadatas[1], 'metadataTypes'=>$metadatas[2], 'cvListModels'=>$metadatas[3], 'entityListModels'=>$metadatas[4], 
        
'treeData'=>1,'roots'=>$roots,'selectedTA'=>array(), 'tagsSAns'=>$tagsSAns));
}

An action set up for record read only page

actionReloadTagcontent() method
public void actionReloadTagcontent()
Source Code: app/controllers/RecordController.php#1794 (show)
public function actionReloadTagcontent(){
    
$recordId $_GET["recordId"];
    
$criteria=new CDbCriteria;
    
$condition='t.recordId='.$recordId;             
     
$criteria->condition $condition;
     
$tagsS tagsStatic::model()->findAll($criteria);
     
$tagsSAns = array();
     foreach(
$tagsS as $tags){
         
$tagsSAns[]=$this->getTagAncestors($tags->tagId);
     }
     
/*$tagContent = "";
    foreach($tagsSAns as $tags){
        $tagsString = "";
        $lastTagId;
        foreach($tags as $tag){
            if($tagsString != "")
                $tagsString .= ">";
            //$tagsString .= $tag->name;
            $tagsString .= CHtml::link($tag->name,array('tags/tag&id='.$tag->id));
            $lastTagId= $tag->id;
        }
        $imghtml =  CHtml::image(Yii::app()->baseUrl.'/images/icon/delete.png', 'Remove record from the category.', array('title'=>'Remove record from the category.', 'width'=>'10px', 'height'=>'10px'));
        $tagContent .= '<span class="round">'.$tagsString." ".CHtml::ajaxLink($imghtml,$this->createUrl('record/deleteTag', array('id'=>$recordId, 'tagId'=>$lastTagId)),array(
            'update'=>'#tagContent'
            ),array('id'=>'delTag_'.$lastTagId, 'confirm'=>"Are you sure you want to remove this record from the category?")).'</span>&nbsp;';
        $tagContent .= " | ";
    }
    echo 'Categories: '.$tagContent. '<span class="round">Add this record to a category.'
    .CHtml::image(Yii::app()->baseUrl.'/images/icon/folderin3.png', 'Drag this icon to the category tree.', array('title'=>'Drag this icon to the category tree.'
    , 'class'=>'jstree-draggable', 'id'=>$recordId, 'width'=>'30px', 'height'=>'30px'
    )).'</span>';*/
     
$this->renderPartialWithHisOwnClientScript('_tagNav', array('tag'=>$tag'recordId'=>$recordId'tagsSAns'=>$tagsSAns),false,true);
}

Reload the category list on the record page after delete/add record from/to categories

actionSaveanota() method
public void actionSaveanota()
Source Code: app/controllers/RecordController.php#1316 (show)
public function actionSaveanota(){
    
    if(isset(
$_GET['id'])){
        
//get annotation to be updated
        
if($_GET['id']!='new'){
            
$anota imgRepsAnnotation::model()->findbyPk($_GET['id']);
        }else
//new annotation
            
$anota = new imgRepsAnnotation();
        
$tmp_text str_replace("\r"''$_GET['text']);
        
$anota->entity1 $_GET['entity1'];
        
$anota->entity2 $_GET['entity2'];
        
$anota->text str_replace("\n"'\n'$tmp_text);
        
$anota->top $_GET['top'];
        
$anota->left $_GET['left'];
        
$anota->width $_GET['width'];
        
$anota->height $_GET['height'];
            
        if(
$anota->save()){
            print 
'{"annotation_id": "'.$anota->id.'"}';
        }
        
//return false;
    
}
}

Create or update image annotation

actionShow() method
public void actionShow()
Source Code: app/controllers/RecordController.php#74 (show)
public function actionShow()
{    
            
    
$projectId Yii::app()->getGlobalState('currentProject');

    
$currentProject entity::model()->findbyPk($projectId);        
    
//load record model
    
$model $this->loadentity();
    
    
$criteria=new CDbCriteria;
    
//show only project space related records
    
$condition='t.type=2';
    
$criteria->condition $condition;
    
$criteria->order ="t.id";            
    
$typemodels entityType::model()->findAll($criteria);
    foreach(
$typemodels as $typemodel){
        
$types[$typemodel->id]=$typemodel->name;
    }
    
//load metadatas for the record model
    
$metadatas $this->loadentitydata();
    
$user Yii::app()->user;
    if(
$user==null||$user->id==null)$this->redirect(array('site/redirectlogin'));    
    
$hasPrjAdmin $this->hasAccess($userroleAccess::ADMIN);
    
$hasPrjWrite $this->hasAccess($userroleAccess::WRITE);
    
$hasPrjRead $this->hasAccess($userroleAccess::READ);
    
    
$projectId Yii::app()->getGlobalState('currentProject');
    
//get project/collection category roots 
    
$roots $this->getTagRoots($projectId);
    if(
$roots==null)$roots=1;
    
    
$criteria=new CDbCriteria;
    
$condition='t.recordId='.$model->id;             
     
$criteria->condition $condition;
     
$tagsS tagsStatic::model()->findAll($criteria);
     
$tagsSAns = array();
     
//get tag hierarchy for showing on records page
     
foreach($tagsS as $tags){
         
$tagsSAns[]=$this->getTagAncestors($tags->tagId);
     }
    
//show update page if user has write+ permission
    
if($hasPrjWrite || $hasPrjAdmin || Yii::app()->user->checkAccess("UserAdmin"))
        
$this->render('showupdate',array('types'=>$types'model'=>$metadatas[0], 'currentProject'=>$currentProject'metadatas'=>$metadatas[1], 'metadataTypes'=>$metadatas[2], 'cvListModels'=>$metadatas[3], 'entityListModels'=>$metadatas[4], 
        
'treeData'=>1,'roots'=>$roots,'selectedTA'=>array(), 'tagsSAns'=>$tagsSAns));
     else 
//show only read page otherwise
        
$this->render('showread',array('types'=>$types'model'=>$metadatas[0], 'currentProject'=>$currentProject'metadatas'=>$metadatas[1], 'metadataTypes'=>$metadatas[2], 'cvListModels'=>$metadatas[3], 'entityListModels'=>$metadatas[4], 
        
'treeData'=>1,'roots'=>$roots,'selectedTA'=>array(), 'tagsSAns'=>$tagsSAns));
}

Shows a particular record.

actionShowfolder() method
public void actionShowfolder()
Source Code: app/controllers/RecordController.php#1072 (show)
public function actionShowfolder()
{    
//         $files = $this->loadfiles();
//         $this->render('showfolder',array('model'=>$this->loadentity(),'filesmodel'=>$files[0], 'pages'=>$files[1], 'record'=>$_GET['record']));

    
$filefolders $this->loadfilefoldersWP();

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

}

Shows a particular folder for selecting file to link.

actionShowfolder4c() method
public void actionShowfolder4c()
Source Code: app/controllers/RecordController.php#1086 (show)
public function actionShowfolder4c()
{    
//         $files = $this->loadfiles();
//         $this->render('showfolder',array('model'=>$this->loadentity(),'filesmodel'=>$files[0], 'pages'=>$files[1], 'record'=>$_GET['record']));
    
$criteria=new CDbCriteria;
    
$criteria->condition "type=2";
    
$criteria->order "t.iOrder";
    
$entityTypes entityType::model()->findAll($criteria);
    
    
$filefolders $this->loadfilefoldersWP();
    
//$model = new entity;
    
$this->render('showfolder4c',array('model'=>$this->loadentity(),'filefoldersmodel'=>$filefolders[0],'filesmodel'=>$filefolders[1],'subfoldersmodel'=>$filefolders[2], 'pages'=>$filefolders[3], 'entityTypes'=>$entityTypes));

}

Shows a particular folder for selecting file to create.

actionShowfolder4cUTag() method
public void actionShowfolder4cUTag()
Source Code: app/controllers/RecordController.php#1105 (show)
public function actionShowfolder4cUTag()
{    
//         $files = $this->loadfiles();
//         $this->render('showfolder',array('model'=>$this->loadentity(),'filesmodel'=>$files[0], 'pages'=>$files[1], 'record'=>$_GET['record']));
    
$criteria=new CDbCriteria;
    
$criteria->condition "type=2";
    
$criteria->order "t.iOrder";
    
$entityTypes entityType::model()->findAll($criteria);
    
    
$filefolders $this->loadfilefoldersWP();
    
$tag tags::model()->findbyPK($_GET['tagId']);
    
//$model = new entity;
    
$this->render('showfolder4cUTag',array('tag'=>$tag'model'=>$this->loadentity(),'filefoldersmodel'=>$filefolders[0],'filesmodel'=>$filefolders[1],'subfoldersmodel'=>$filefolders[2], 'pages'=>$filefolders[3], 'entityTypes'=>$entityTypes));

}

Shows a particular folder for selecting file to create under tag.

actionShowgroups() method
public void actionShowgroups()
Source Code: app/controllers/RecordController.php#1124 (show)
public function actionShowgroups()
{    

    if(
$id!==null || isset($_GET['id'])){
        
$id = ($id!=null) ? $id $_GET['id'];
        
$criteria=new CDbCriteria;
        
$condition='t.typeId='.entityType::GROUP_TYPE;
         
$condition=$condition.' AND relation1.entity2='.$id;
         
$condition=$condition.' AND relation1.typeId='.relationType::IS_PART_OF;
        
$criteria->condition $condition;
        
$pages=new CPagination(entity::model()->with('relation1')->together()->count($criteria));
        
$pages->pageSize=self::PAGE_SIZE;
        
$pages->applyLimit($criteria);

        
$groupsmodel=entity::model()->with('relation1')->together()->findAll($criteria);
    }if(
$groupsmodel===null)
        throw new 
CHttpException(404,'The requested page does not exist.');

    
$this->render('showgroups',array('id'=>$id,'model'=>$this->loadentity(),'groupsmodel'=>$groupsmodel'record'=>$_GET['record'], 'pages'=>$pages));

}

Shows sets for selecting record to link.

actionShowimagetbn() method
public void actionShowimagetbn()
Source Code: app/controllers/RecordController.php#734 (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/";    
        
$pThumb->fit_thumbnail(Yii::app()->params['ajPath']."/files/".$path.$name200);
        if(
$pThumb->isError()){
            
print_r($pThumb->error_array);
        }
        exit(
0);
    }

}

Shows record image thumbnail (moved to fileController)

actionShowrecords() method
public void actionShowrecords()
Source Code: app/controllers/RecordController.php#1149 (show)
public function actionShowrecords()
{    
    
$form = new RelationForm();
    if(isset(
$_GET['id'])){
        
$id $_GET['id'];
        
$criteria=new CDbCriteria;
        
$condition='(entityType.type=2)';
        
$condition=$condition.' AND relation1.entity2='.$id;
         
$condition=$condition.' AND relation1.typeId='.relationType::IS_PART_OF;
        
$criteria->condition $condition;
        
$pages=new CPagination(entity::model()->with('relation1','entityType')->together()->count($criteria));
        
$pages->pageSize=self::PAGE_SIZE;
        
$pages->applyLimit($criteria);

        
$recordsmodel=entity::model()->with('relation1','entityType')->together()->findAll($criteria);
    }if(
$recordsmodel===null)
        throw new 
CHttpException(404,'The requested page does not exist.');

    
$this->render('showrecords',array('form'=>$form,'id'=>$id,'model'=>$this->loadentity(),'recordsmodel'=>$recordsmodel'record'=>$_GET['record'],'pages'=>$pages));

}

Shows records for selecting records to link.

actionUpdate() method
public void actionUpdate()
Source Code: app/controllers/RecordController.php#757 (show)
public function actionUpdate()
{
    
$criteria=new CDbCriteria;
    
$criteria->condition "type=2";
    
$criteria->order "t.iOrder";
    
$entityTypes entityType::model()->findAll($criteria);
    
$types = array();
    foreach(
$entityTypes as $entityType){
        
$types[$entityType->id]=$entityType->name;
    }
    
$metadatas=$this->loadentitydata();
    
$model $metadatas[0];

    
//for save
    
if(isset($_POST['entity']))
    {
        
$model->attributes=$_POST['entity'];
        
$model->timeModified=date("Y-m-d H-i-s"time());
        
$metadatas $_POST['metadatas'];
        
$newMetadatas $_POST['newMetadatas'];
        
$newInputs $_POST['input_newMetadatas'];
        
$cFilled=1;
        
$index=0;
        if(
$metadatas!=null){
            
$m=0;
            
//fields marked with * compulsory have to be filled, otherwise reports error
            
foreach($metadatas as $n=>$value):
                
$metadata metadata::model()->findbyPk($n);        
                
$type prjMetadataType::model()->findbyPk($metadata->typeId);
                
$typeName $type->name;
                
//update name according to the first field //tmp solution for name title
                
if($m==0){
                    
$model->name $value;
                }
                if(
strpos($typeName'*')&&($value==null||trim($value)=='')){                    
                    
$cFilled 0;
                    
$model->addError('name'$typeName.' cannot be blank.');
                }
/*else if(strpos($typeName, '*')){
                    if($index==0){
                        $model->name = $value;
                    }
                    $index=1;
                }*/    
                
$m++;                
            endforeach;
        }
        if(
$cFilled){//compulsory fields are filled
            
if($metadatas!=null){
                foreach(
$metadatas as $n=>$value):
                    
                    
$metadata metadata::model()->findbyPk($n);
                    if(
trim($value)=="")
                        
$metadata->delete();
                    else{
                        
$metadata->content $value;
                        
$metadata->save();
                    }
                endforeach;
            }
            if(
$newMetadatas!=null){
                foreach(
$newMetadatas as $typeId=>$value):
                    
$metadataType prjMetadataType::model()->findbyPk($typeId);
                    if(
$metadataType->sourceType==metadataType::SOURCE_FILLEDIN){
                        
$metadata = new metadata;
                        
$metadata->typeId $typeId;
                        
$metadata->content $value;
                        
$metadata->entityId $model->id;
                        
                        
$metadata->save();
                    }else if(
$metadataType->sourceType==metadataType::SOURCE_CVLIST){//save for controlled vocabulary list field metadata
                        
$oldCvListRelas $model->cvListRela;
                        foreach(
$oldCvListRelas as $rela)
                            
$rela->delete();
                        if(
$metadataType->isMultiple){
                            foreach(
$value as $cvListId){
                                
$cvListRela = new cvListRela;
                                
$cvListRela->entityId $model->id;
                                
$cvListRela->cvListId $cvListId;
                                
$cvListRela->metadataTypeId $metadataType->id;
                                
$cvListRela->save();
                            }
                        }else{
                            
$cvListRela = new cvListRela;
                            
$cvListRela->entityId $model->id;
                            
$cvListRela->cvListId $value;
                            
$cvListRela->metadataTypeId $metadataType->id;
                            
$cvListRela->save();
                        }
                    }else if(
$metadataType->sourceType==metadataType::SOURCE_ENTITYLIST){//save for record link list field metadata
                        
$oldEntityListRelas $model->entityListRela;
                        foreach(
$oldEntityListRelas as $rela)
                            
$rela->delete();
                        if(
$metadataType->isMultiple){
                            foreach(
$value as $entityListId){
                                
$entityListRela = new entityListRela;
                                
$entityListRela->entityId $model->id;
                                
$entityListRela->entityListId $entityListId;
                                
$entityListRela->metadataTypeId $metadataType->id;
                                
$entityListRela->save();
                            }
                        }else{
                            
$entityListRela = new entityListRela;
                            
$entityListRela->entityId $model->id;
                            
$entityListRela->entityListId $value;
                            
$entityListRela->metadataTypeId $metadataType->id;
                            
$entityListRela->save();
                        }
                    }
                endforeach;
            }
            
            if(
$newInputs!=null){//input new controlled vocabulary list items if the list is not fixed
                
foreach($newInputs as $typeId=>$value):
                    if(
trim($value)!=''){                        
                        
$cvType $_POST['newinputCvType'][$typeId];
                        
$metadataType prjMetadataType::model()->findbyPk($typeId);
                        
                        if(
$cvType!=null){
                            
$existed false;
                            
$criteria=new CDbCriteria;
                            
$condition='typeId='.$cvType;
                            
$criteria->condition $condition;
                            
$cvTypeLists=cvList::model()->findAll($criteria);
                            
                            foreach(
$cvTypeLists as $list){
                                if(
$list->name==$value)
                                    
$existed=true;
                            }
                            
                            if(!
$existed&&$metadataType->cvListType->fixed!=1){
                                
$cvList = new cvList;
                                
$cvList->name $value;
                                
$cvList->typeId $cvType;
                                
$cvList->save();
                                
$cvListRela = new cvListRela;
                                
$cvListRela->entityId $model->id;
                                
$cvListRela->cvListId $cvList->id;
                                
$cvListRela->metadataTypeId $typeId;
                                
$cvListRela->save();
                            }
                        }
                    }
                endforeach;
            }
        }
        if(
$model->save())
            
$this->redirect(array('show','id'=>$model->id));
    }
    
        
    
    
$currentProject_id Yii::app()->getGlobalState('currentProject');

    
$currentProject entity::model()->findbyPk($currentProject_id);

    
//$model = $this->loadentity();
    //for show update page
    
    
$this->render('update',array('model'=>$model,'types'=>$types'metadatas'=>$metadatas[1], metadataTypes=>$metadatas[2], 'currentProject'=>$currentProject));
}

Updates a particular record model. If update is successful, the browser will be redirected to the 'show' page.

actionView() method
public void actionView()
Source Code: app/controllers/RecordController.php#169 (show)
public function actionView()
{    
    
$this->actionShow();
}

same action as show, create for view in gridview widget

copyMetadata() method
public void copyMetadata(integer $fromentity, integer $toentity)
$fromentity integer
$toentity integer
Source Code: app/controllers/RecordController.php#2301 (show)
public function copyMetadata($fromentity$toentity){ 

    
$frommetas $fromentity->metadata;
    
$tometas $toentity->metadata;
    
//substr($_GET['entity2'], 0, strpos($_GET['entity2'],"?"));
    
    
foreach($frommetas as $froma){
        
$new true;
        
$fromtype $froma->fileMetadataType->name;
        if(
strpos($fromtype,"*")!==false)
            
$fromtype trim(substr($fromtype0strpos($fromtype,"*")));
        else
            
$fromtype trim($fromtype);
        foreach(
$tometas as $toa){                
            
$totype $toa->metadataType->name;
            if(
strpos($totype,"*")!==false)            
                
$totype trim(substr($totype0strpos($totype,"*")));
            else
                
$totype trim($totype);
            if(
$fromtype==$totype){
                
$toa->content $froma->content;
                
$toa->save();
                
$new false;
            }
        }
        if(
$new){
            
$metatypes $toentity->entityType->metadataType;
            foreach(
$metatypes as $metatype){
                
$typename $metatype->name;
                if(
strpos($typename,"*")!==false)
                    
$typename trim(substr($typename0strpos($typename,"*")));
                else
                    
$typename trim($typename);
                if(
$fromtype==$typename){
                    
$meta = new metadata();
                    
$meta->content $froma->content;
                    
$meta->typeId $metatype->id;
                    
$meta->entityId $toentity->id;
                    
$meta->save();
                }
            }
        }
    }
}

Copy filled in metadata only from one entity to the other (file to record)

copyMetadata2() method
public void copyMetadata2(integer $fromentity, integer $toentity, array $recordMetadataIds, array $fileMetadataIds)
$fromentity integer from entity model
$toentity integer to entity model
$recordMetadataIds array record metadata mapping by ids
$fileMetadataIds array file metadata mapping by ids
Source Code: app/controllers/RecordController.php#2352 (show)
public function copyMetadata2($fromentity$toentity$recordMetadataIds$fileMetadataIds){ 

    
$frommetas $fromentity->metadata;
    
$tometas $toentity->metadata;
    
//substr($_GET['entity2'], 0, strpos($_GET['entity2'],"?"));
    
    
foreach($frommetas as $froma){
        
$new true;
        
$fromtype $froma->fileMetadataType->id;//print 'fromtype:'.$froma->id.'<br/>';
        
        
if($froma->fileMetadataType->sourceType==metadataType::SOURCE_FILLEDIN){
            foreach(
$tometas as $toa){                
                
$totype $toa->metadataType->id;
                foreach(
$fileMetadataIds as $i=>$fileMetadataId){
                    if(
$fromtype==$fileMetadataId&&$totype==$recordMetadataIds[$i]){
                        
$toa->content $froma->content;
                        
$toa->save();
                        
$new false;
                    }
                }
            }
            if(
$new){
                
                foreach(
$fileMetadataIds as $j=>$fileMetadataId){//print $fromtype.":".$fileMetadataId.'<br/>';
                    
if($fromtype==$fileMetadataId){
                        
$totype=$recordMetadataIds[$j];
                        if(
$totype!=null){
                            
$toMetaType prjMetadataType::model()->findbyPk($totype);
                            if(
$toMetaType->sourceType==metadataType::SOURCE_FILLEDIN){//copy filled in metadata                        
                                
$meta = new metadata();
                                
$meta->content $froma->content;
                                
$meta->typeId $totype;
                                
$meta->entityId $toentity->id;
                                
$meta->save();        
                            }else if(
$toMetaType->sourceType==metadataType::SOURCE_CVLIST&&trim($froma->content)!=''){    //copy controlled vocabulary field metadata

                                
$cvLists $toMetaType->cvListType->cvList;
                                
$addCv true;//add new cv or not
                                
foreach($cvLists as $cvList){
                                    if(
$cvList->name==$froma->content){
                                        
$addCv false;
                                        
$cvListRela = new cvListRela();
                                        
$cvListRela->entityId $toentity->id;;
                                        
$cvListRela->cvListId $cvList->id;
                                        
$cvListRela->metadataTypeId $totype;
                                        
$cvListRela->save();
                                    }
                                }
                                
//add froma content to cvlist before adding metadata in cvListRela
                                
if($addCv&&$toMetaType->cvListType->fixed==0){
                                    
$cvList = new cvList();
                                    
$cvList->name=$froma->content;
                                    
$cvList->typeId $toMetaType->cvListType->id;
                                    
$cvList->save();
                                    
$cvListRela = new cvListRela();
                                    
$cvListRela->entityId $toentity->id;;
                                    
$cvListRela->cvListId $cvList->id;
                                    
$cvListRela->metadataTypeId $totype;
                                    
$cvListRela->save();
                                }
                                
                            }
                        }
                    }
                }
            }
        }
    }
}

Copy (filled in, controlled vocabulary) metadata from one entity to the other (file to record) according to metadata mapping

creatRecordfFile() method
public void creatRecordfFile(integer $fileId, integer $typeId, integer $tagId)
$fileId integer
$typeId integer
$tagId integer
Source Code: app/controllers/RecordController.php#2071 (show)
public function creatRecordfFile($fileId$typeId$tagId){
    
$file=entity::model()->findbyPk($fileId);
    if(
$file!=null){
        
$record=new entity;
        
$record->typeId $typeId;
        
$record->timeCreated=date("Y-m-d H-i-s"time());
        
$record->timeModified=date("Y-m-d H-i-s"time());
        
$fileMetadatas $file->metadata;
        
$title="";
        foreach(
$fileMetadatas as $filemetadata){
            if(
$filemetadata->fileMetadataType->name=="Title *")
                
$title $filemetadata->content;
        }
        if(
$title!=""){
            
$record->name $title;
            
        }else
            throw new 
CHttpException("Can't find Title metadata from file");
        
        if(
$record->save()){
            
//$this->link2Group($record,Yii::app()->getGlobalState('currentSet'));
            
$this->link2Project($record,Yii::app()->getGlobalState('currentProject'));
            
//link to tag is tagId is not null
            
if($tagId!=null)
                
$this->link2Tag($record,$tagId);
            
$this->link2File($record->id,$fileId);
            
//copy metadata from file to record
            
$this->copyMetadata($file$record);
        }
    }
    
}

Create records from files

creatRecordfFile2() method
public void creatRecordfFile2(integer $fileId, integer $typeId, array $recordMetadataIds, array $fileMetadataIds, integer $tagId)
$fileId integer
$typeId integer
$recordMetadataIds array
$fileMetadataIds array
$tagId integer
Source Code: app/controllers/RecordController.php#2112 (show)
public function creatRecordfFile2($fileId$typeId$recordMetadataIds$fileMetadataIds$tagId){
    
$file=entity::model()->findbyPk($fileId);
    if(
$file!=null){
        
$record=new entity;
        
$record->typeId $typeId;
        
$record->timeCreated=date("Y-m-d H-i-s"time());
        
$record->timeModified=date("Y-m-d H-i-s"time());
        
$fileMetadatas $file->metadata;
        
$title="";
        foreach(
$fileMetadatas as $filemetadata){
            if(
$filemetadata->fileMetadataType->name=="Title *"||$filemetadata->fileMetadataType->name=="Title")
                
$title $filemetadata->content;
        }
        if(
$title!=""){
            
$record->name $title;
            
        }else
            throw new 
CHttpException("Can't find Title metadata from file");
        
//print $record->typeId;
        
if($record->save()){
            
//$record->name = $record->entityType->id."_".$record->id;
            //$record->save();
            //$this->link2Group($record,Yii::app()->getGlobalState('currentSet'));
            
$this->link2Project($record,Yii::app()->getGlobalState('currentProject'));
            
//link to tag is tagId is not null
            
if($tagId!=null)
                
$this->link2Tag($record,$tagId);
            
$this->link2File($record->id,$fileId);
            
//copy metadata from file to record
            
$this->copyMetadata2($file$record,$recordMetadataIds$fileMetadataIds);
        }
    }
    
}

Create records from files

deleteRecord() method
public void deleteRecord($id)
$id
Source Code: app/controllers/RecordController.php#1845 (show)
public function deleteRecord($id){
    
$record entity::model()->findByPk($id);
    
//delete metadata
    
$existMetadata metadata::model()->findAllByAttributes(array('entityId'=>$id));    
    if(
$existMetadata!=null)
        foreach(
$existMetadata as $metadata)
            
$metadata->delete();
    
$cvListRelas $model->cvListRela;
    if(
$cvListRelas!=null)
        foreach(
$cvListRelas as $rela)
            
$rela->delete();
    
    
$entityListRelas $model->entityListRela;
    if(
$entityListRelas!=null)
        foreach(
$entityListRelas as $rela)
            
$rela->delete();
                                
    
//delete relationship
    
$relation1s $record->relation1;
    if(
$relation1s!=null)
        foreach(
$relation1s as $rela)
            
$rela->delete();
    
$relation2s $record->relation2;
    if(
$relation2s!=null)
        foreach(
$relation2s as $rela)
            
$rela->delete();
            
    
//delete role, access, userrole
    
$roles $record->role;
    if(
$roles!=null)
    foreach(
$roles as $role){
        
//delete userRole and roleAccess            
        
$roleAccesses $role->roleAccess;
        foreach(
$roleAccesses as $roleAcc){
            
$roleAcc->delete();
        }
        
$userRoles $role->userRole;
        foreach(
$userRoles as $userRole){
            
$userRole->delete();
        }
        
//delete role
        
$role->delete();
    }        
    
    
//delete tagsStatic
     
$criteria=new CDbCriteria;
    
$condition='t.recordId='.$record->id;             
     
$criteria->condition $condition;
     
$tagsS tagsStatic::model()->findAll($criteria);
     if(
$tagsS!=null)
         foreach(
$tagsS as $tags){
             
$tags->delete();
         }
    
//delete record        
    
    
$record->delete();
    if(
$_SESSION['hold']!=null)
        unset(
$_SESSION['hold'][array_search($id$_SESSION['hold'])]);
}

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

getChildTreeData() method
protected void getChildTreeData(integer $id, integer $expandId1=NULL, integer $expandId2=NULL)
$id integer
$expandId1 integer
$expandId2 integer
Source Code: app/controllers/RecordController.php#2487 (show)
protected function getChildTreeData($id$expandId1=null$expandId2=null){
    
$data = array();
    
$criteria=new CDbCriteria;
     
$condition='relation1.entity2='.$id;
     
$condition=$condition.' AND relation1.typeId='.relationType::IS_PART_OF;
     
$criteria->condition $condition;
     
$criteria->order="t.id";
     
$models=entity::model()->with('relation1')->together()->findAll($criteria);
     foreach(
$models as $model){
         
$childs $this->getChildTreeData($model->id$expandId1$expandId2); 
         if(
count($childs)>0)$hasChildren=true;
         if(
$model->typeId==entityType::SET_TYPE)
             
$link='set/show';
         else 
$link='record/show';
         
$expanded=false;
         
$class='';
        if((
$expandId1!=null&&$expandId1==$model->id)||($expandId2!=null&&$expandId2==$model->id)){
            
$expanded=true;
            
$class="treeselected";
        }
         
array_push($data, array(text=>CHtml::link($model->name,array($link,'id'=>$model->id), array('class'=>$class)), id=>$model->idexpanded=>$expandedhasChildren=>$hasChildrenchildren=>$childs ));
     }
     return 
$data;
}

Get sub tree data (old version)

getDescendants() method
public tag getDescendants(integer $id)
$id integer
{return} tag hierarchy models
Source Code: app/controllers/RecordController.php#2549 (show)
public function getDescendants($id){
    
$criteria=new CDbCriteria;
     
$condition='t.ancestorId='.$id;         
     
$criteria->order"t.depth, t.weight";    
     
$criteria->condition $condition;
     
$tagHs tagsHierarchy::model()->findAll($criteria);
     return 
$tagHs;
}

Get category descendant tag hierarchy models by category id

getMetadataTypes() method
public project getMetadataTypes(integer $entityType)
$entityType integer
{return} project metadata type models
Source Code: app/controllers/RecordController.php#2151 (show)
public function getMetadataTypes($entityType){
    
$currentProject_id Yii::app()->getGlobalState('currentProject');
    
$criteria=new CDbCriteria;
    
$condition='entityType='.$entityType.' and prjId='.$currentProject_id;
    
$criteria->condition $condition;
    
$criteria->order "t.dOrder, t.id";
    
$models=prjMetadataType::model()->findAll($criteria);

    return 
$models;
}

Get project metadata types according to entity type

getPrjMetadataType() method
public models getPrjMetadataType(integer $entityType)
$entityType integer
{return} models $metadataTypes
Source Code: app/controllers/RecordController.php#2445 (show)
public function getPrjMetadataType($entityType){
    
$currentProject_id Yii::app()->getGlobalState('currentProject');
    
$criteria=new CDbCriteria;
    
$condition='entityType='.$entityType.' and prjId='.$currentProject_id;            
    
$criteria->condition $condition;
//        /$criteria->select = "t.id as id, t.name as name";
    
$metadataTypes=prjMetadataType::model()->findAll($criteria);
    return 
$metadataTypes;
}

Get project metadata type according to entity type

getRecordPrjId() method
public integer getRecordPrjId(integer $recordId)
$recordId integer
{return} integer $prjId or null
Source Code: app/controllers/RecordController.php#2426 (show)
public function getRecordPrjId($recordId){
    
$model entity::model()->findbyPk($recordId);
    
$prjrelation1s $model->relation1;
    if(
$prjrelation1s!=null)
    foreach(
$prjrelation1s as $relation1){
        if(
$relation1->typeId==relationType::IS_PART_OF){
            if(
$relation1->entity2entity->typeId==entityType::PROJECT_TYPE){            
                
$prjId $relation1->entity2entity->id;
                return 
$prjId;
            }
        }
    }
    return 
null;
}

Get record project id according to record id

getTagAncestors() method
protected array getTagAncestors(integer $id)
$id integer
{return} array $tags
Source Code: app/controllers/RecordController.php#2530 (show)
protected function getTagAncestors($id){
    if(
$id!=null){
        
$criteria=new CDbCriteria;
         
$condition='t.descendantId='.$id;         
         
$criteria->order"t.depth DESC, t.weight";    
         
$criteria->condition $condition;
         
$tagHs tagsHierarchy::model()->findAll($criteria);
         
$tags = array();
         foreach(
$tagHs as $tagH){
             
$tags[] = tags::model()->findbyPk($tagH->ancestorId);
         }
         return 
$tags;
    }else return array();
}

Get category ancestor tag models by category id

getTagRoots() method
protected models getTagRoots(integer $projectId)
$projectId integer
{return} models $roots
Source Code: app/controllers/RecordController.php#2516 (show)
protected function getTagRoots($projectId){
    
$criteria=new CDbCriteria;
     
$condition='t.isRoot=1 and t.projectId='.$projectId;             
     
$criteria->condition $condition;
     
$criteria->order "t.name";
     
$roots tags::model()->findAll($criteria);
    return 
$roots;
    
}

Get category root tag models for project/collection

getTreeData() method
protected void getTreeData(integer $id=NULL, integer $expandId1=NULL, integer $expandId2=NULL)
$id integer
$expandId1 integer
$expandId2 integer
Source Code: app/controllers/RecordController.php#2460 (show)
protected function getTreeData($id=null$expandId1=null$expandId2=null){
    
$tree = array();
    
$criteria=new CDbCriteria;
    
$condition='typeId='.entityType::COLLECTION_TYPE;
    
$criteria->condition $condition;
    
$criteria->order="t.id";
    
$projectmodels=entity::model()->findAll($criteria);
    
    foreach(
$projectmodels as $projectmodel){
        
$childs $this->getChildTreeData($projectmodel->id$expandId1$expandId2);
        if(
count($childs)>0)$hasChildren=true;
        
$expanded=false;
        
$class='';
        if(
$id!=null&&$id==$projectmodel->id){
            
$expanded=true;
            
$class="treeselected";
        }
        
array_push($tree, array(text=>CHtml::link($projectmodel->name,array('collection/show','id'=>$projectmodel->id),array('class'=>$class)), id=>$projectmodel->idexpanded=>$expandedhasChildren=>$hasChildrenchildren=>$childs ));
    }    
    return 
$tree;
}

Get tree data (old verson)

hasAccess() method
public void hasAccess(model $user, integer $access)
$user model
$access integer
Source Code: app/controllers/RecordController.php#2562 (show)
public function hasAccess($user$access){

    
$prjId Yii::app()->getGlobalState('currentProject');
    
    if(isset(
$_GET['prjId'])&&$_GET['prjId']!=null){            
        
$prjId $_GET['prjId'];
        
    }else{
        
$model $this->loadentity();
        
$prjrelation1s $model->relation1;
        if(
$prjrelation1s!=null)
        foreach(
$prjrelation1s as $relation1){
            if(
$relation1->typeId==relationType::IS_PART_OF){
                    
$prjId $relation1->entity2entity->id;
                    break;
            }
            
        }            
    }
    
Yii::app()->setGlobalState('currentProject'$prjId);
    
    
$hasAccess 0;
    
    
    if(
$prjId!=null){
        
$criteria=new CDbCriteria
        
        
$condition='t.entityId='.$prjId.' 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;
}

link2File() method
protected boolean link2File(integer $recordId, integer $fileId)
$recordId integer
$fileId integer
{return} boolean return true if succeed
Source Code: app/controllers/RecordController.php#1965 (show)
protected function link2File($recordId$fileId){//echo "entityid:".$entity->id.",folderid:".$folderId.", relationType".relationType::IS_PART_OF;
    
try{
        
$relation = new relation;
        
$relation->entity1$fileId;
        
$relation->entity2 $recordId;
        
$relation->name "main";
        
$relation->typeId relationType::REPRESENTS;
        
$relation->save();
        return 
true;
    }catch(
CDbException $e){
        echo 
'relationship already exists.';
    }
}

Link record to file

link2Group() method
protected void link2Group(model $entity, integer $groupId)
$entity model
$groupId integer
Source Code: app/controllers/RecordController.php#1940 (show)
protected function link2Group($entity$groupId){//echo "entityid:".$entity->id.",folderid:".$folderId.", relationType".relationType::IS_PART_OF;
    
$relation = new relation;
    
$relation->entity1$entity->id;
    
$relation->entity2 $groupId;
    
$relation->typeId relationType::IS_PART_OF;
    
$relation->save();
}

Link record to group/set (old version)

link2Project() method
protected void link2Project(model $entity, integer $projectId)
$entity model
$projectId integer
Source Code: app/controllers/RecordController.php#1952 (show)
protected function link2Project($entity$projectId){//echo "entityid:".$entity->id.",folderid:".$folderId.", relationType".relationType::IS_PART_OF;
    
$relation = new relation;
    
$relation->entity1$entity->id;
    
$relation->entity2 $projectId;
    
$relation->typeId relationType::IS_PART_OF;
    
$relation->save();
}

Link record to project/collection

link2Tag() method
protected void link2Tag(model $entity, integer $tagId)
$entity model
$tagId integer
Source Code: app/controllers/RecordController.php#1923 (show)
protected function link2Tag($entity$tagId){//echo "entityid:".$entity->id.",folderid:".$folderId.", relationType".relationType::IS_PART_OF;
    
$criteria=new CDbCriteria;
    
$condition='t.tagId='.$tagId.' and t.recordId='.$entity->id;             
     
$criteria->condition $condition;
     
$tagsS tagsStatic::model()->findAll($criteria);
     if(!(
sizeof($tagsS)>0)){        
        
$tagsStatic = new tagsStatic();
        
$tagsStatic->recordId $entity->id;
        
$tagsStatic->tagId $tagId;
        
$tagsStatic->save();
     }
}

Link record to category

link2record() method
protected void link2record(integer $recordId, integer $linkrecordId, string $name, string $content)
$recordId integer record ID of the first selected record
$linkrecordId integer record ID of the record has been linked to
$name string name of the relationship
$content string description of the relationship
Source Code: app/controllers/RecordController.php#1985 (show)
protected function link2record($recordId$linkrecordId$name$content){
    if(
$recordId!=$linkrecordId)
        try{
            
$relation = new relation;
            
$relation->entity1$recordId;
            
$relation->entity2 $linkrecordId;
            
$relation->name $name;
            
$relation->content $content;
            
$relation->typeId relationType::RELATES;
            
$relation->save();
        }catch(
CDbException $e){
            echo 
'relationship already exists.';
        }
        
}

Link record to record

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/RecordController.php#1832 (show)
public function loadentity($id=null)
{
    
    if(
$id!==null || isset($_GET['id'])){
        
$id = ($id!=null) ? $id $_GET['id'];
        
$model=entity::model()->findbyPk($id);

    }
    return 
$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.

loadentitydata() method
protected array loadentitydata(integer $id=NULL)
$id integer
{return} array $modelsarray the record model, the filled metadata model, the metadata types model, the controlled vocabulary list field metadata model and the record link list field metadata model
Source Code: app/controllers/RecordController.php#2007 (show)
protected function loadentitydata($id=null)
{
    
$metadataModel=array();
    
//if($this->_model===null)
    //{
        
if($id!==null || isset($_GET['id'])){
            
$id = ($id!=null) ? $id $_GET['id'];
            
$this->_model=entity::model()->findbyPk($id!==null $id $_GET['id']);
            
            
$metadataTypes $this->getMetadataTypes($this->_model->typeId);

            
$criteria=new CDbCriteria;
            
$condition='entity.id='.$id;
            
$criteria->order "metadataType.id";
             
//$criteria->select = 'entity.id as id, entity.typeId as typeId, entity.name as name, metadata.content as metadata, metadataType.name as metadataName';
            
$criteria->condition $condition;

            
$metadataModel=metadata::model()->with('entity','metadataType')->together()->findAll($criteria);
            
            
$criteria=new CDbCriteria;
            
$condition='t.entityId='.$id;
            
$criteria->condition $condition;
            
            
$cvListModels cvListRela::model()->with('cvList')->together()->findAll($criteria);
            
            
$entityListModels entityListRela::model()->with('entityList')->together()->findAll($criteria);
        }if(
$this->_model===null)
            throw new 
CHttpException(404,'The requested page does not exist.');
    
//}
    
return array($this->_model,$metadataModel$metadataTypes,$cvListModels,$entityListModels);
}

Load metadata (filled in, controlled vocabulary and record link list) of the current record model and its metadata types

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

    if(
$this->_filesmodel===null)
    {
        if(
$id!==null || isset($_GET['id'])){
            
$id = ($id!=null) ? $id $_GET['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''entityType')->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'];
            
$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'];
            
$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=25;
            
$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/RecordController.php#2221 (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'];
            
            
$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'];
            
            
$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'];
        
        
$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=25;
        
$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

loadfiles() method
public void loadfiles(integer $id=NULL)
$id integer
Source Code: app/controllers/RecordController.php#2042 (show)
public function loadfiles($id=null){

    if(
$this->_filesmodel===null)
    {
        if(
$id!==null || isset($_GET['id'])){
            
$id = ($id!=null) ? $id $_GET['id'];
            
$criteria=new CDbCriteria;
            
$condition='t.typeId='.entityType::IMAGE_TYPE;
             
$condition=$condition.' AND relation1.entity2='.$id;
             
$condition=$condition.' AND relation1.typeId='.relationType::IS_PART_OF;
            
$criteria->condition $condition;
            
$pages=new CPagination(entity::model()->with('relation1')->together()->count($criteria));
            
$pages->pageSize=self::PAGE_SIZE;
            
$pages->applyLimit($criteria);

            
$this->_filesmodel=entity::model()->with('relation1')->together()->findAll($criteria);
        }if(
$this->_filesmodel===null)
            throw new 
CHttpExceptionfile(404,'The requested page does not exist.');
    }
    return array(
$this->_filesmodel,$pages) ;

}

Load file models according to its parent (folder) id

processAdminCommand() method
protected void processAdminCommand()
Source Code: app/controllers/RecordController.php#1908 (show)
protected function processAdminCommand()
{
    if(isset(
$_POST['command'], $_POST['id']) && $_POST['command']==='delete')
    {
        
$this->loadentity($_POST['id'])->delete();
        unset(
$_SESSION['hold'][array_search($_POST['id'], $_SESSION['hold'])]);
        
// 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.