Example #1
0
 /**
  * Function returns list of folders
  * @return <Array> folder list
  */
 public static function getAllFolders()
 {
     $db = PearDatabase::getInstance();
     $result = $db->pquery('SELECT * FROM vtiger_attachmentsfolder ORDER BY sequence', array());
     $folderList = array();
     for ($i = 0; $i < $db->num_rows($result); $i++) {
         $row = $db->query_result_rowdata($result, $i);
         $folderList[] = Documents_Folder_Model::getInstanceByArray($row);
     }
     return $folderList;
 }
Example #2
0
 public function delete($request)
 {
     $moduleName = $request->getModule();
     $folderId = $request->get('folderid');
     $result = array();
     if (!empty($folderId)) {
         $folderModel = Documents_Folder_Model::getInstanceById($folderId);
         if (!$folderModel->hasDocuments()) {
             $folderModel->delete();
             $result = array('success' => true, 'message' => vtranslate('LBL_FOLDER_DELETED', $moduleName));
         } else {
             $result = array('success' => false, 'message' => vtranslate('LBL_FOLDER_HAS_DOCUMENTS', $moduleName));
         }
     }
     $response = new Vtiger_Response();
     $response->setResult($result);
     $response->emit();
 }
Example #3
0
 /**
  * Function returns an instance of Folder Model
  * @param <Array> row
  * @return Documents_Folder_Model
  */
 public static function getInstanceByArray($row)
 {
     $folderModel = Documents_Folder_Model::getInstance();
     return $folderModel->setData($row);
 }
Example #4
0
 public function getListDocForModule($moduleName, $forCheck = false)
 {
     $db = PearDatabase::getInstance();
     // $this->createFunctionName('is not');
     $sql = "SELECT " . "vtiger_ossdocumentcontrol.ossdocumentcontrolid as id, " . "vtiger_ossdocumentcontrol.doc_name as doc_name, " . "vtiger_ossdocumentcontrol.doc_request as doc_request, " . "vtiger_ossdocumentcontrol.doc_folder as doc_folder " . "FROM vtiger_ossdocumentcontrol " . "WHERE module_name = ? ";
     if ($forCheck) {
         $sql .= " AND vtiger_ossdocumentcontrol.doc_request = '1'";
     }
     $sql .= " ORDER BY vtiger_ossdocumentcontrol.doc_order ASC";
     $result = $db->pquery($sql, array($moduleName), TRUE);
     $output = array();
     for ($i = 0; $i < $db->num_rows($result); $i++) {
         $output[$i]['doc_id'] = $db->query_result($result, $i, 'id');
         $output[$i]['doc_name'] = $db->query_result($result, $i, 'doc_name');
         $output[$i]['doc_request'] = $db->query_result($result, $i, 'doc_request');
         $folderId = $db->query_result($result, $i, 'doc_folder');
         $folderModel = Documents_Folder_Model::getInstanceById($folderId);
         $output[$i]['doc_folder'] = $folderId;
         $output[$i]['folder_name'] = $folderModel->getName();
     }
     return $output;
 }