示例#1
0
 public function delete($where = null)
 {
     $cache_dir = PRIVATE_PATH . '/data/cache/' . $this->getModelName();
     App_Util::remove_dir($cache_dir);
     App_Util::remove_dir(CACHE_OUTPUT_DIR);
     if ($where == null) {
         $pkcol = $this->getPkColumn();
         $pkpop = $this->getPKName();
         $pkval = $this->{$pkpop};
         $where = "{$pkcol} = '{$pkval}'";
     }
     $this->getMapper()->delete($where, $this);
     $this->_handleAffterDeleted($this);
     if ("Sys_Model_AppLog" != $this->getModelName()) {
         $models = explode("_Model_", $this->getModelName());
         $modelName = strtolower($models[1]);
         $id = $this->getMapper()->getLastInsertId();
         $message = "deleted {$modelName} {$pkcol}:{$pkval}";
         App_Log::get()->addlog(array("remark" => $where, "message" => $message, "activity" => "delete", "refType" => $this->getModelName(), "refId" => $id));
     }
     return $this;
 }
示例#2
0
     $userFolderPath = self::getSession("pathOfUserTemporaryFolder", "");
     if (!is_dir($userFolderPath)) {
         self::createUserTemporaryFolder();
     }
     return self::getSession("pathOfUserTemporaryFolder", "");
 }
 static function createUserTemporaryFolder()
 {
     $userFolderName = strtolower(App_Formatter::cleanFileNames(App_Env::getUser()->getLoginid()));
     $userFolderPath = TEM_DOCUMENTS . "/" . $userFolderName;
     if (!is_dir($userFolderPath)) {
         @mkdir($userFolderPath, 0777, true);
示例#3
0
 public static function remove_dir($dir)
 {
     //echo (int)is_dir($dir);
     //die();
     // if(!is_dir($dir)){
     //		 $dir = dirname ($dir);
     // }
     // if(is_dir($dir))
     //{
     $dir = substr($dir, -1) != "/" ? $dir . "/" : $dir;
     chmod($dir, 0777);
     $openDir = opendir($dir);
     //echo $openDir;
     while ($file = readdir($openDir)) {
         if (!in_array($file, array(".", ".."))) {
             if (!is_dir($dir . $file)) {
                 @unlink($dir . $file);
             } else {
                 App_Util::remove_dir($dir . $file);
             }
         }
     }
     closedir($openDir);
     // echo (int) rmdir($dir);
     //}
 }
示例#4
0
 public function ajaxSwopAction()
 {
     try {
         $this->_helper->layout->disableLayout();
         $request = $this->getRequest();
         $id1 = $request->getParam('id1');
         $id2 = $request->getParam('id2');
         $mode = $request->getParam('mode', '');
         $newIndex = $request->getParam('newIndex');
         $model1 = $this->getObject($this->_model);
         $model2 = $this->getObject($this->_model);
         $dbTable = $model1->getDbTable();
         $model1->find($id1);
         $model2->find($id2);
         $index1 = $model1->ordering;
         $index2 = $model2->ordering;
         $pkcol = $model1->getPkColumn();
         $db = $dbTable->getAdapter();
         $tableName = $dbTable->getName();
         //die('pkcol'.$pkcol);
         if ($mode == 'top') {
             //ย้ายมาไว้ที่0
             //	echo "UPDATE $tableName SET odering = 0 WHERE $pkcol = $id1";
             $dbTable->update(array('ordering' => '0'), "{$pkcol} = '{$id1}' ");
             // move ทราต่ำกว่า ขึ้น 1 ระดับ
             $where = array();
             $where1 = $where2 = '';
             if ($this->_section != '') {
                 $where1 = '  secid=' . $this->_section;
                 $where[] = $where1;
             }
             $where2 = ' ordering > ' . $index1;
             $where[] = $where2;
             $db->query("UPDATE {$tableName} SET ordering = ordering-1 WHERE " . join(' AND ', $where));
             // move ทั้งหมดลง
             if (trim($where1) == '') {
                 $db->query("UPDATE {$tableName} SET ordering = ordering+1");
             } else {
                 $db->query("UPDATE {$tableName} SET ordering = ordering+1 WHERE " . $where1);
             }
             //$db->query ( "UPDATE $tableName SET ordering = ordering+1 WHERE " . $where1 );
             //$db->query("UPDATE $tableName SET odering = 1 WHERE $pkcol = $id1");
             //$dbTable->update(array('odering'=>$index2+1),"$pkcol = $id1 ");
         } elseif ($mode == 'bottom') {
             // move id ที่ต่ำกว่า ขึ้นมา 1
             $dbTable->update(array('ordering' => $index2 + 1), "{$pkcol} = '{$id1}' ");
             $where = 'ordering > ' . $index1;
             if ($this->_section != '') {
                 $where .= ' and secid=' . $this->_section;
             }
             $db = $dbTable->getAdapter();
             $tableName = $dbTable->getName();
             $db->query("UPDATE {$tableName} SET ordering = ordering-1 WHERE " . $where);
         } else {
             $dbTable->update(array('ordering' => $index2), "{$pkcol} = '{$id1}' ");
             $dbTable->update(array('ordering' => $index1), "{$pkcol} = '{$id2}' ");
         }
         //  exit();
         $result = array('result' => 'success');
     } catch (Exception $e) {
         $result = array('result' => 'failed');
     }
     $cache_dir = PRIVATE_PATH . '/data/cache';
     App_Util::remove_dir($cache_dir);
     App_Util::remove_dir(CACHE_OUTPUT_DIR);
     echo json_encode($result);
     $this->render('blank', null, true);
 }