Пример #1
0
 public function actionRenameDocument($document, $newName)
 {
     // local user variables
     $local_user_name = Yii::app()->user->name;
     $model = User::model()->find("username=:username", array(':username' => $local_user_name));
     $local_user_id = $model->id;
     $local_user_real_name = $model->first_name . ' ' . $model->last_name;
     $user = $local_user_name;
     $homeFolder = '/var/www/html/JobFair/userHomes';
     $userHomeFolder = $homeFolder . "/" . $user;
     $userSaveFiles = $userHomeFolder . "/saveFiles";
     // 		$docId="";
     // 		if ( (strpos($document, '.doc') == TRUE) ){
     $docId = substr($document, 0, -4);
     // 	echo 'it had a doc extension';
     // 		} else {
     // 			$docId = $document
     // 		}
     $condition = 'owner_id = ' . $local_user_id;
     // this is clearing all active user documents
     echo "docId = " . $docId;
     echo "<br>";
     echo "document = " . $document;
     $rename = UserDocument::model()->find('document_id=:document_id AND owner_id=:owner_id', array(':document_id' => $docId, ':owner_id' => $local_user_id));
     $rename->document_name = $newName;
     $rename->save(false);
     //$this->render('renameDocument');
 }
Пример #2
0
 public function dataUserDocuments($userId)
 {
     if (isset($userId)) {
         $documents = UserDocument::where('user_id', '=', $userId)->where('status', '=', 'active')->get();
         if (isset($documents) && count($documents) > 0) {
             return json_encode(array('message' => 'found', 'documents' => $documents->toArray()));
         } else {
             return json_encode(array('message' => 'empty'));
         }
     } else {
         return json_encode(array('message' => 'invalid'));
     }
 }