Example #1
0
 public function updateTest($testID, $companyID, $testName)
 {
     //--- validate
     $errMsg = "";
     if (empty($testName)) {
         $errMsg = 'Test Name is empty';
     }
     $otherID = $this->GetTestIDByTestName($testName, $companyID);
     if (!empty($otherID) && $otherID != $testID) {
         $errMsg = 'TestName already existed.';
     }
     if (!empty($errMsg)) {
         $errors = PR_Api_Error::getInstance();
         $errors->addError(6, $errMsg);
         return array("success" => 0, "errMsg" => $errMsg);
     }
     //test
     //TestID,CompanyID,posteddate,createdBy,TestName
     $updateFields = array('TestName' => $testName);
     $criteria = "TestID = '{$testID}'";
     $result = PR_Database::update("test", $updateFields, $criteria);
     $result = $this->create($updateFields);
     $testID = $this->GetTestIDByTestName($testName, $companyID);
     return array("success" => 1, "errMsg" => '');
 }
Example #2
0
 /**
  * Singleton
  * @return Core_Api_Error
  */
 public static function getInstance()
 {
     if (self::$instance == NULL) {
         self::$instance = new PR_Api_Error();
     }
     return self::$instance;
 }
Example #3
0
 /**
  * Check up user information
  *
  * @param array $authData
  * @return bool
  */
 public function loadAndCheckAuthentication($authData)
 {
     $errors = PR_Api_Error::getInstance();
     $this->authenticate = false;
     if (empty($authData['emailaddress']) || empty($authData['password'])) {
         $errors->addError(2, 'emailaddress or password is empty but required');
         return false;
     }
     $user = $this->getClientArray($authData);
     if (!empty($user)) {
         $this->authenticate = true;
     }
     return $user;
 }
Example #4
0
 public function save($data = null)
 {
     $errors = PR_Api_Error::getInstance();
     if (empty($data)) {
         return;
     }
     if (empty($this->NotificationID)) {
         //
         $objDateNow = new Zend_Date();
         $data['cbDateTime'] = $objDateNow->toString('yyyy-MM-dd hh:mm:ss');
         $data['lmDateTime'] = $objDateNow->toString('yyyy-MM-dd hh:mm:ss');
         if (empty($data['NotificationType'])) {
             $data['NotificationType'] = 2;
             //private noti.
         }
         //if(empty($data['NotificationType'])){
         //    $data['cbUserTypeID'] = 1; //client create nodifications
         // }
         //echo "<pre>";
         //print_r($data['receiver_iduser']);
         //echo "</pre>"; die();
         $dataBk = array();
         $dataBk = $data['receiver_iduser'];
         foreach ($dataBk as $k => $v) {
             $data['receiver_iduser'] = $v;
             $res = $this->insert($data);
         }
         if ($res) {
             return new $this($res);
         }
     } else {
         try {
             unset($data['NotificationID']);
             $objDateNow = new Zend_Date();
             $data['lmDateTime'] = $objDateNow->toString('yyyy-MM-dd hh:mm:ss');
             $res = $this->update($data, 'NotificationID = ' . $this->NotificationID);
         } catch (Exception $e) {
             $errors->addError('7', 'Incorrect SQL request');
         }
         if ($res) {
             foreach ($data as $k => $v) {
                 $this->{$k} = $v;
             }
             return $this;
         }
     }
     return null;
 }
Example #5
0
 public function Add($updateFields)
 {
     $userName = $updateFields['username'];
     //--- validate
     if (empty($userName)) {
         $errors = PR_Api_Error::getInstance();
         $errors->addError(6, 'User Name is empty');
         return false;
     } else {
         $userObj = $this->GetUserByUserName($userName);
         if (!empty($userObj)) {
             $errors = PR_Api_Error::getInstance();
             $errors->addError(6, 'User Name already existed.');
             return false;
         }
     }
     //--- insert
     $result = PR_Database::insert("users", $updateFields);
     return $result;
 }
Example #6
0
 public function saveCareer($data = null)
 {
     $errors = PR_Api_Error::getInstance();
     if (empty($data)) {
         return;
     }
     if (empty($this->OpportunityID)) {
         $objDateNow = new Zend_Date();
         $data['posteddate'] = $objDateNow->toString('yyyy-MM-dd hh:mm:ss');
         $res = $this->insert($data);
         if ($res) {
             return new $this($res);
         }
     } else {
         try {
             unset($data['OpportunityID']);
             $objDateNow = new Zend_Date();
             $data['posteddate'] = $objDateNow->toString('yyyy-MM-dd hh:mm:ss');
             /*  echo "<pre>";
                 print_r($data);
                 echo "<pre>"; die(); */
             $res = $this->update($data, 'OpportunityID = ' . $this->OpportunityID);
         } catch (Exception $e) {
             $errors->addError('7', 'Incorrect SQL request');
         }
         if ($res) {
             foreach ($data as $k => $v) {
                 $this->{$k} = $v;
             }
             return $this;
         } else {
             return 1;
         }
     }
     return null;
 }
Example #7
0
 public static function fetchAll(Zend_Db_Select $select, &$count = null)
 {
     self::init();
     $result = false;
     try {
         $limit = $select->getPart(Zend_Db_Select::LIMIT_COUNT);
         $offset = $select->getPart(Zend_Db_Select::LIMIT_OFFSET);
         $result = $select->query()->fetchAll();
         if ($count !== null) {
             $count = self::getCount($select);
         }
     } catch (Exception $e) {
         $errors = PR_Api_Error::getInstance();
         $errors->addError(7, 'SQL Error: ' . $select . " " . $e);
         error_log($e);
         $result = false;
     }
     return $result;
 }