コード例 #1
0
ファイル: UserTest.php プロジェクト: youprofit/casebox
 public function testIdExists()
 {
     $id = DM\Users::toId($this->testName);
     $this->assertTrue(DM\Users::idExists($id), 'Id doesnt exist');
     $this->assertTrue(!DM\Users::idExists(-$id), 'Id exist');
 }
コード例 #2
0
ファイル: Files.php プロジェクト: sebbie42/casebox
 private function validateInputParamsForUpload(&$p)
 {
     if (!isset($p['pid'])) {
         return 'pid not specified';
     }
     if (!is_numeric($p['pid'])) {
         return 'pid not valid';
     }
     if (empty($p['template_id']) && !empty($p['tmplId'])) {
         $p['template_id'] = $p['tmplId'];
     }
     if (empty($p['template_id'])) {
         $p['template_id'] = \CB\Config::get('default_file_template');
         if (empty($p['template_id'])) {
             return 'template not specified';
         }
     }
     if (!empty($p['fileExistAction'])) {
         if (!in_array($p['fileExistAction'], array('newversion', 'replace', 'autorename'))) {
             return 'Invalid value for fileExistAction';
         }
         $p['response'] = $p['fileExistAction'];
         unset($p['fileExistAction']);
     }
     if (!is_numeric($p['template_id'])) {
         return 'template id not valid';
     }
     if (!empty($p['localFile'])) {
         if (!file_exists($p['localFile'])) {
             return 'File not found: ' . $p['localFile'];
         }
     } else {
         if (empty($_FILES)) {
             return 'No file found for upload';
         }
     }
     if (empty($p['title'])) {
         if (!empty($p['filename'])) {
             $p['title'] = $p['filename'];
             unset($p['filename']);
         } else {
             if (!empty($p['localFile'])) {
                 $p['title'] = basename($p['localFile']);
             } elseif (!empty($_FILES['file'])) {
                 $p['title'] = $_FILES['file']['name'];
             }
         }
     }
     if (empty($p['title'])) {
         return 'Cannot detect file title';
     }
     if (!isset($p['oid'])) {
         if (!isset($p['owner'])) {
             return 'owner not specified';
         }
         if (is_numeric($p['owner'])) {
             if (DM\Users::idExists($p['owner'])) {
                 $p['oid'] = $p['owner'];
             }
         } else {
             $p['oid'] = DM\Users::getIdByName($p['owner']);
         }
     }
     if (!is_numeric($p['oid'])) {
         return 'invalid owner specified';
     } elseif (empty($p['cid'])) {
         $p['cid'] = $p['oid'];
     }
     return true;
 }