当前位置: 首页>>代码示例>>PHP>>正文


PHP Validator::getErrorsArray方法代码示例

本文整理汇总了PHP中Validator::getErrorsArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Validator::getErrorsArray方法的具体用法?PHP Validator::getErrorsArray怎么用?PHP Validator::getErrorsArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Validator的用法示例。


在下文中一共展示了Validator::getErrorsArray方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: returnFileValidationError

 function returnFileValidationError()
 {
     //Make sure we return a complete validation error to be displayed to the user.
     $validator_obj = new Validator();
     $validator_stats = array('total_records' => 1, 'valid_records' => 0);
     $validator_obj->isTrue('file', FALSE, TTi18n::getText('Please upload file again'));
     $validator[0] = $validator_obj->getErrorsArray();
     return $this->returnHandler(FALSE, 'IMPORT_FILE', TTi18n::getText('INVALID DATA'), $validator, $validator_stats);
 }
开发者ID:alachaum,项目名称:timetrex,代码行数:9,代码来源:APIImport.class.php

示例2: deleteUser

 /**
  * Delete one or more users.
  * @param array $data user data
  * @return array
  */
 function deleteUser($data)
 {
     if (is_numeric($data)) {
         $data = array($data);
     }
     if (DEMO_MODE == TRUE) {
         return $this->returnHandler(TRUE);
     }
     if (!is_array($data)) {
         return $this->returnHandler(FALSE);
     }
     if (!$this->getPermissionObject()->Check('user', 'enabled') or !($this->getPermissionObject()->Check('user', 'delete') or $this->getPermissionObject()->Check('user', 'delete_own') or $this->getPermissionObject()->Check('user', 'delete_child'))) {
         return $this->getPermissionObject()->PermissionDenied();
     }
     //Get Permission Hierarchy Children first, as this can be used for viewing, or editing.
     $permission_children_ids = $this->getPermissionChildren();
     Debug::Text('Received data for: ' . count($data) . ' Users', __FILE__, __LINE__, __METHOD__, 10);
     Debug::Arr($data, 'Data: ', __FILE__, __LINE__, __METHOD__, 10);
     $total_records = count($data);
     $validator_stats = array('total_records' => $total_records, 'valid_records' => 0);
     if (is_array($data)) {
         $this->getProgressBarObject()->start($this->getAMFMessageID(), $total_records);
         foreach ($data as $key => $id) {
             $primary_validator = new Validator();
             $lf = TTnew('UserListFactory');
             $lf->StartTransaction();
             if (is_numeric($id)) {
                 if ($this->getPermissionObject()->Check('company', 'view') == TRUE) {
                     $lf->getById($id);
                     //Allow deleting employees in other companies.
                 } else {
                     $lf->getByIdAndCompanyId($id, $this->getCurrentCompanyObject()->getId());
                 }
                 if ($lf->getRecordCount() == 1) {
                     //Object exists, check edit permissions
                     //Debug::Text('User ID: '. $user['id'] .' Created By: '. $lf->getCurrent()->getCreatedBy() .' Is Owner: '. (int)$this->getPermissionObject()->isOwner( $lf->getCurrent()->getCreatedBy(), $lf->getCurrent()->getID() ) .' Is Child: '. (int)$this->getPermissionObject()->isChild( $lf->getCurrent()->getId(), $permission_children_ids ), __FILE__, __LINE__, __METHOD__, 10);
                     if ($this->getPermissionObject()->Check('user', 'delete') or $this->getPermissionObject()->Check('user', 'delete_own') and $this->getPermissionObject()->isOwner($lf->getCurrent()->getCreatedBy(), $lf->getCurrent()->getID()) === TRUE or $this->getPermissionObject()->Check('user', 'delete_child') and $this->getPermissionObject()->isChild($lf->getCurrent()->getId(), $permission_children_ids) === TRUE) {
                         Debug::Text('Record Exists, deleting record: ', $id, __FILE__, __LINE__, __METHOD__, 10);
                         $lf = $lf->getCurrent();
                     } else {
                         $primary_validator->isTrue('permission', FALSE, TTi18n::gettext('Delete permission denied'));
                     }
                 } else {
                     //Object doesn't exist.
                     $primary_validator->isTrue('id', FALSE, TTi18n::gettext('Delete permission denied, record does not exist'));
                 }
             } else {
                 $primary_validator->isTrue('id', FALSE, TTi18n::gettext('Delete permission denied, record does not exist'));
             }
             //Debug::Arr($lf, 'AData: ', __FILE__, __LINE__, __METHOD__, 10);
             $is_valid = $primary_validator->isValid();
             if ($is_valid == TRUE) {
                 //Check to see if all permission checks passed before trying to save data.
                 Debug::Text('Attempting to delete record...', __FILE__, __LINE__, __METHOD__, 10);
                 $lf->setDeleted(TRUE);
                 $is_valid = $lf->isValid();
                 if ($is_valid == TRUE) {
                     Debug::Text('Record Deleted...', __FILE__, __LINE__, __METHOD__, 10);
                     $save_result[$key] = $lf->Save();
                     $validator_stats['valid_records']++;
                 }
             }
             if ($is_valid == FALSE) {
                 Debug::Text('Data is Invalid...', __FILE__, __LINE__, __METHOD__, 10);
                 $lf->FailTransaction();
                 //Just rollback this single record, continue on to the rest.
                 if ($primary_validator->isValid() == FALSE) {
                     $validator[$key] = $primary_validator->getErrorsArray();
                 } else {
                     $validator[$key] = $lf->Validator->getErrorsArray();
                 }
             }
             $lf->CommitTransaction();
             $this->getProgressBarObject()->set($this->getAMFMessageID(), $key);
         }
         $this->getProgressBarObject()->stop($this->getAMFMessageID());
         if ($validator_stats['valid_records'] > 0 and $validator_stats['total_records'] == $validator_stats['valid_records']) {
             if ($validator_stats['total_records'] == 1) {
                 return $this->returnHandler($save_result[$key]);
                 //Single valid record
             } else {
                 return $this->returnHandler(TRUE, 'SUCCESS', TTi18n::getText('MULTIPLE RECORDS SAVED'), $save_result, $validator_stats);
                 //Multiple valid records
             }
         } else {
             return $this->returnHandler(FALSE, 'VALIDATION', TTi18n::getText('INVALID DATA'), $validator, $validator_stats);
         }
     }
     return $this->returnHandler(FALSE);
 }
开发者ID:alachaum,项目名称:timetrex,代码行数:95,代码来源:APIUser.class.php

示例3: deleteUserPreference

 /**
  * Delete one or more UserPreferences.
  * @param array $data UserPreference data
  * @return array
  */
 function deleteUserPreference($data)
 {
     if (is_numeric($data)) {
         $data = array($data);
     }
     if (!is_array($data)) {
         return $this->returnHandler(FALSE);
     }
     if (!$this->getPermissionObject()->Check('user_preference', 'enabled') or !($this->getPermissionObject()->Check('user_preference', 'delete') or $this->getPermissionObject()->Check('user_preference', 'delete_own') or $this->getPermissionObject()->Check('user_preference', 'delete_child'))) {
         return $this->getPermissionObject()->PermissionDenied();
     }
     Debug::Text('Received data for: ' . count($data) . ' UserPreferences', __FILE__, __LINE__, __METHOD__, 10);
     Debug::Arr($data, 'Data: ', __FILE__, __LINE__, __METHOD__, 10);
     $total_records = count($data);
     $validator_stats = array('total_records' => $total_records, 'valid_records' => 0);
     if (is_array($data)) {
         $this->getProgressBarObject()->start($this->getAMFMessageID(), $total_records);
         foreach ($data as $key => $id) {
             $primary_validator = new Validator();
             $lf = TTnew('UserPreferenceListFactory');
             $lf->StartTransaction();
             if (is_numeric($id)) {
                 //Modifying existing object.
                 //Get UserPreference object, so we can only modify just changed data for specific records if needed.
                 $lf->getByIdAndCompanyId($id, $this->getCurrentCompanyObject()->getId());
                 if ($lf->getRecordCount() == 1) {
                     //Object exists, check edit permissions
                     if ($this->getPermissionObject()->Check('user_preference', 'delete') or $this->getPermissionObject()->Check('user_preference', 'delete_own') and $this->getPermissionObject()->isOwner($lf->getCurrent()->getCreatedBy(), $lf->getCurrent()->getID()) === TRUE) {
                         Debug::Text('Record Exists, deleting record: ', $id, __FILE__, __LINE__, __METHOD__, 10);
                         $lf = $lf->getCurrent();
                     } else {
                         $primary_validator->isTrue('permission', FALSE, TTi18n::gettext('Delete permission denied'));
                     }
                 } else {
                     //Object doesn't exist.
                     $primary_validator->isTrue('id', FALSE, TTi18n::gettext('Delete permission denied, record does not exist'));
                 }
             } else {
                 $primary_validator->isTrue('id', FALSE, TTi18n::gettext('Delete permission denied, record does not exist'));
             }
             //Debug::Arr($lf, 'AData: ', __FILE__, __LINE__, __METHOD__, 10);
             $is_valid = $primary_validator->isValid();
             if ($is_valid == TRUE) {
                 //Check to see if all permission checks passed before trying to save data.
                 Debug::Text('Attempting to delete record...', __FILE__, __LINE__, __METHOD__, 10);
                 $lf->setDeleted(TRUE);
                 $is_valid = $lf->isValid();
                 if ($is_valid == TRUE) {
                     Debug::Text('Record Deleted...', __FILE__, __LINE__, __METHOD__, 10);
                     $save_result[$key] = $lf->Save();
                     $validator_stats['valid_records']++;
                 }
             }
             if ($is_valid == FALSE) {
                 Debug::Text('Data is Invalid...', __FILE__, __LINE__, __METHOD__, 10);
                 $lf->FailTransaction();
                 //Just rollback this single record, continue on to the rest.
                 if ($primary_validator->isValid() == FALSE) {
                     $validator[$key] = $primary_validator->getErrorsArray();
                 } else {
                     $validator[$key] = $lf->Validator->getErrorsArray();
                 }
             }
             $lf->CommitTransaction();
             $this->getProgressBarObject()->set($this->getAMFMessageID(), $key);
         }
         $this->getProgressBarObject()->stop($this->getAMFMessageID());
         if ($validator_stats['valid_records'] > 0 and $validator_stats['total_records'] == $validator_stats['valid_records']) {
             if ($validator_stats['total_records'] == 1) {
                 return $this->returnHandler($save_result[$key]);
                 //Single valid record
             } else {
                 return $this->returnHandler(TRUE, 'SUCCESS', TTi18n::getText('MULTIPLE RECORDS SAVED'), $save_result, $validator_stats);
                 //Multiple valid records
             }
         } else {
             return $this->returnHandler(FALSE, 'VALIDATION', TTi18n::getText('INVALID DATA'), $validator, $validator_stats);
         }
     }
     return $this->returnHandler(FALSE);
 }
开发者ID:alachaum,项目名称:timetrex,代码行数:86,代码来源:APIUserPreference.class.php

示例4: deleteUserGenericData

 /**
  * Delete one or more users.
  * @param array $data user data
  * @return array
  */
 function deleteUserGenericData($data)
 {
     Debug::Arr($data, 'DataA: ', __FILE__, __LINE__, __METHOD__, 10);
     if (is_numeric($data)) {
         $data = array($data);
     }
     if (!is_array($data)) {
         return $this->returnHandler(FALSE);
     }
     Debug::Text('Received data for: ' . count($data) . ' Users', __FILE__, __LINE__, __METHOD__, 10);
     Debug::Arr($data, 'Data: ', __FILE__, __LINE__, __METHOD__, 10);
     $total_records = count($data);
     $validator_stats = array('total_records' => $total_records, 'valid_records' => 0);
     if (is_array($data)) {
         foreach ($data as $key => $id) {
             $primary_validator = new Validator();
             $lf = TTnew('UserGenericDataListFactory');
             $lf->StartTransaction();
             if (is_numeric($id)) {
                 //Modifying existing object.
                 //Get user object, so we can only modify just changed data for specific records if needed.
                 $lf->getByUserIdAndId($this->getCurrentUserObject()->getId(), $id);
                 if ($lf->getRecordCount() == 1) {
                     //Object exists
                     Debug::Text('User Generic Data Exists, deleting record: ', $id, __FILE__, __LINE__, __METHOD__, 10);
                     $lf = $lf->getCurrent();
                 } else {
                     //Object doesn't exist.
                     $primary_validator->isTrue('id', FALSE, TTi18n::gettext('Delete permission denied, generic data does not exist'));
                 }
             } else {
                 $primary_validator->isTrue('id', FALSE, TTi18n::gettext('Delete permission denied, generic data does not exist'));
             }
             //Debug::Arr($lf, 'AData: ', __FILE__, __LINE__, __METHOD__, 10);
             $is_valid = $primary_validator->isValid();
             if ($is_valid == TRUE) {
                 //Check to see if all permission checks passed before trying to save data.
                 Debug::Text('Attempting to delete user generic data...', __FILE__, __LINE__, __METHOD__, 10);
                 $lf->setDeleted(TRUE);
                 $is_valid = $lf->isValid();
                 if ($is_valid == TRUE) {
                     Debug::Text('User Deleted...', __FILE__, __LINE__, __METHOD__, 10);
                     $save_result[$key] = $lf->Save();
                     $validator_stats['valid_records']++;
                 }
             }
             if ($is_valid == FALSE) {
                 Debug::Text('User Generic Data is Invalid...', __FILE__, __LINE__, __METHOD__, 10);
                 $lf->FailTransaction();
                 //Just rollback this single record, continue on to the rest.
                 if ($primary_validator->isValid() == FALSE) {
                     $validator[$key] = $primary_validator->getErrorsArray();
                 } else {
                     $validator[$key] = $lf->Validator->getErrorsArray();
                 }
             }
             $lf->CommitTransaction();
         }
         if ($validator_stats['valid_records'] > 0 and $validator_stats['total_records'] == $validator_stats['valid_records']) {
             if ($validator_stats['total_records'] == 1) {
                 return $this->returnHandler($save_result[$key]);
                 //Single valid record
             } else {
                 return $this->returnHandler(TRUE, 'SUCCESS', TTi18n::getText('MULTIPLE RECORDS SAVED'), $save_result, $validator_stats);
                 //Multiple valid records
             }
         } else {
             return $this->returnHandler(FALSE, 'VALIDATION', TTi18n::getText('INVALID DATA'), $validator, $validator_stats);
         }
     }
     return $this->returnHandler(FALSE);
 }
开发者ID:alachaum,项目名称:timetrex,代码行数:77,代码来源:APIUserGenericData.class.php

示例5: Login

 function Login($user_name, $password = NULL, $type = 'USER_NAME')
 {
     global $config_vars;
     $authentication = new Authentication();
     Debug::text('User Name: ' . $user_name . ' Password Length: ' . strlen($password) . ' Type: ' . $type, __FILE__, __LINE__, __METHOD__, 10);
     //FIXME: When using Flex, I think it sets the cookie itself, so we need to pass this information on to it before it will actually work.
     //However this should work fine for JSON/SOAP.
     //FIXME: Store the type in the authentication table so we know how the user logged in. Then we can disable certain functionality if using the phone_id.
     if (isset($config_vars['other']['web_session_expire']) and $config_vars['other']['web_session_expire'] != '') {
         $authentication->setEnableExpireSession((int) $config_vars['other']['web_session_expire']);
     }
     if ($authentication->Login($user_name, $password, $type) === TRUE) {
         $retval = $authentication->getSessionId();
         Debug::text('Success, Session ID: ' . $retval, __FILE__, __LINE__, __METHOD__, 10);
         return $retval;
     } else {
         $validator_obj = new Validator();
         $validator_stats = array('total_records' => 1, 'valid_records' => 0);
         $error_column = 'user_name';
         $error_message = TTi18n::gettext('User Name or Password is incorrect');
         //Get company status from user_name, so we can display messages for ONHOLD/Cancelled accounts.
         $clf = TTnew('CompanyListFactory');
         $clf->getByUserName($user_name);
         if ($clf->getRecordCount() > 0) {
             $c_obj = $clf->getCurrent();
             if ($c_obj->getStatus() == 20) {
                 $error_message = TTi18n::gettext('Sorry, your company\'s account has been placed ON HOLD, please contact customer support immediately');
             } elseif ($c_obj->getStatus() == 23) {
                 $error_message = TTi18n::gettext('Sorry, your trial period has expired, please contact our sales department to reactivate your account');
             } elseif ($c_obj->getStatus() == 28) {
                 if ($c_obj->getMigrateURL() != '') {
                     $error_message = TTi18n::gettext('To better serve our customers your account has been migrated, please update your bookmarks to use the following URL from now on: ') . 'http://' . $c_obj->getMigrateURL();
                 } else {
                     $error_message = TTi18n::gettext('To better serve our customers your account has been migrated, please contact customer support immediately.');
                 }
             } elseif ($c_obj->getStatus() == 30) {
                 $error_message = TTi18n::gettext('Sorry, your company\'s account has been CANCELLED, please contact customer support if you believe this is an error');
             } elseif ($c_obj->getPasswordPolicyType() == 1 and $c_obj->getProductEdition() > 10) {
                 //Password policy is enabled, confirm users password has not exceeded maximum age.
                 $ulf = TTnew('UserListFactory');
                 $ulf->getByUserName($user_name);
                 if ($ulf->getRecordCount() > 0) {
                     foreach ($ulf as $u_obj) {
                         //Make sure we confirm that the password is in fact correct, but just expired.
                         if ($u_obj->checkPassword($password, FALSE) == TRUE and $u_obj->checkPasswordAge() == FALSE) {
                             $error_message = TTi18n::gettext('Sorry, your password has exceeded its maximum age specified by your company\'s password policy and must be changed immediately');
                             $error_column = 'password';
                         }
                     }
                 }
                 unset($ulf, $u_obj);
             }
         }
         $validator_obj->isTrue($error_column, FALSE, $error_message);
         $validator[0] = $validator_obj->getErrorsArray();
         return $this->returnHandler(FALSE, 'VALIDATION', TTi18n::getText('INVALID DATA'), $validator, $validator_stats);
     }
     return $this->returnHandler(FALSE);
 }
开发者ID:alachaum,项目名称:timetrex,代码行数:59,代码来源:APIAuthentication.class.php

示例6: setLog

 /**
  * Set log data for one or more loges.
  * @param array $data log data
  * @return array
  */
 function setLog($data, $validate_only = FALSE)
 {
     $validate_only = (bool) $validate_only;
     if (!is_array($data)) {
         return $this->returnHandler(FALSE);
     }
     if ($validate_only == TRUE) {
         Debug::Text('Validating Only!', __FILE__, __LINE__, __METHOD__, 10);
     }
     extract($this->convertToMultipleRecords($data));
     Debug::Text('Received data for: ' . $total_records . ' Logs', __FILE__, __LINE__, __METHOD__, 10);
     Debug::Arr($data, 'Data: ', __FILE__, __LINE__, __METHOD__, 10);
     $validator_stats = array('total_records' => $total_records, 'valid_records' => 0);
     if (is_array($data)) {
         $this->getProgressBarObject()->start($this->getAMFMessageID(), $total_records);
         foreach ($data as $key => $row) {
             $primary_validator = new Validator();
             $lf = TTnew('LogListFactory');
             $lf->StartTransaction();
             //Can add log entries only.
             unset($row['id']);
             Debug::Arr($row, 'Data: ', __FILE__, __LINE__, __METHOD__, 10);
             Debug::Text('Setting object data...', __FILE__, __LINE__, __METHOD__, 10);
             $lf->setObjectFromArray($row);
             //Force Company ID to current company.
             $lf->setUser($this->getCurrentUserObject()->getId());
             $is_valid = $lf->isValid();
             if ($is_valid == TRUE) {
                 Debug::Text('Saving data...', __FILE__, __LINE__, __METHOD__, 10);
                 if ($validate_only == TRUE) {
                     $save_result[$key] = TRUE;
                 } else {
                     $save_result[$key] = $lf->Save();
                 }
                 $validator_stats['valid_records']++;
             }
             if ($is_valid == FALSE) {
                 Debug::Text('Data is Invalid...', __FILE__, __LINE__, __METHOD__, 10);
                 $lf->FailTransaction();
                 //Just rollback this single record, continue on to the rest.
                 if ($primary_validator->isValid() == FALSE) {
                     $validator[$key] = $primary_validator->getErrorsArray();
                 } else {
                     $validator[$key] = $lf->Validator->getErrorsArray();
                 }
             }
             $lf->CommitTransaction();
             $this->getProgressBarObject()->set($this->getAMFMessageID(), $key);
         }
         $this->getProgressBarObject()->stop($this->getAMFMessageID());
         if ($validator_stats['valid_records'] > 0 and $validator_stats['total_records'] == $validator_stats['valid_records']) {
             if ($validator_stats['total_records'] == 1) {
                 return $this->returnHandler($save_result[$key]);
                 //Single valid record
             } else {
                 return $this->returnHandler(TRUE, 'SUCCESS', TTi18n::getText('MULTIPLE RECORDS SAVED'), $save_result, $validator_stats);
                 //Multiple valid records
             }
         } else {
             return $this->returnHandler(FALSE, 'VALIDATION', TTi18n::getText('INVALID DATA'), $validator, $validator_stats);
         }
     }
     return $this->returnHandler(FALSE);
 }
开发者ID:alachaum,项目名称:timetrex,代码行数:69,代码来源:APILog.class.php

示例7: deleteRecurringScheduleControl

 /**
  * Delete one or more recurring_schedule_controls.
  * @param array $data recurring_schedule_control data
  * @return array
  */
 function deleteRecurringScheduleControl($data)
 {
     if (is_numeric($data)) {
         $data = array($data);
     }
     if (!is_array($data)) {
         return $this->returnHandler(FALSE);
     }
     if (!$this->getPermissionObject()->Check('recurring_schedule', 'enabled') or !($this->getPermissionObject()->Check('recurring_schedule', 'delete') or $this->getPermissionObject()->Check('recurring_schedule', 'delete_own') or $this->getPermissionObject()->Check('recurring_schedule', 'delete_child'))) {
         return $this->getPermissionObject()->PermissionDenied();
     }
     //Get Permission Hierarchy Children first, as this can be used for viewing, or editing.
     $permission_children_ids = $this->getPermissionChildren();
     Debug::Text('Received data for: ' . count($data) . ' RecurringScheduleControls', __FILE__, __LINE__, __METHOD__, 10);
     Debug::Arr($data, 'Data: ', __FILE__, __LINE__, __METHOD__, 10);
     $total_records = count($data);
     $validator_stats = array('total_records' => $total_records, 'valid_records' => 0);
     if (is_array($data)) {
         $this->getProgressBarObject()->start($this->getAMFMessageID(), $total_records);
         foreach ($data as $key => $tmp_id) {
             $primary_validator = new Validator();
             $lf = TTnew('RecurringScheduleControlListFactory');
             $lf->StartTransaction();
             //Need to support deleting the entire recurring schedule, or just one user from it.
             if (is_array($tmp_id)) {
                 $id = $key;
                 $user_id = $tmp_id;
                 Debug::Arr($tmp_id, 'ID is an array, with User ID specified as well, deleting just this one user: ID: ' . $id . ' User IDs: ', __FILE__, __LINE__, __METHOD__, 10);
             } else {
                 $id = $tmp_id;
                 $user_id = FALSE;
             }
             if (is_numeric($id)) {
                 //Modifying existing object.
                 //Get recurring_schedule_control object, so we can only modify just changed data for specific records if needed.
                 $lf->getByIdAndCompanyId($id, $this->getCurrentCompanyObject()->getId());
                 if ($lf->getRecordCount() == 1) {
                     //Object exists, check edit permissions
                     if ($this->getPermissionObject()->Check('recurring_schedule', 'delete') or $this->getPermissionObject()->Check('recurring_schedule', 'delete_own') and $this->getPermissionObject()->isOwner($lf->getCurrent()->getCreatedBy(), $lf->getCurrent()->getID()) === TRUE or $this->getPermissionObject()->Check('recurring_schedule', 'delete_child') and $this->getPermissionObject()->isChild($user_id, $permission_children_ids) === TRUE) {
                         //if ( $this->getPermissionObject()->Check('recurring_schedule','delete')
                         //		OR ( $this->getPermissionObject()->Check('recurring_schedule','delete_own') AND $this->getPermissionObject()->isOwner( $lf->getCurrent()->getCreatedBy(), $lf->getCurrent()->getID() ) === TRUE ) ) {
                         Debug::Text('Record Exists, deleting record: ', $id, __FILE__, __LINE__, __METHOD__, 10);
                         $lf = $lf->getCurrent();
                     } else {
                         $primary_validator->isTrue('permission', FALSE, TTi18n::gettext('Delete permission denied'));
                     }
                 } else {
                     //Object doesn't exist.
                     $primary_validator->isTrue('id', FALSE, TTi18n::gettext('Delete permission denied, record does not exist'));
                 }
             } else {
                 $primary_validator->isTrue('id', FALSE, TTi18n::gettext('Delete permission denied, record does not exist'));
             }
             //Debug::Arr($lf, 'AData: ', __FILE__, __LINE__, __METHOD__, 10);
             $is_valid = $primary_validator->isValid();
             if ($is_valid == TRUE) {
                 //Check to see if all permission checks passed before trying to save data.
                 Debug::Text('Attempting to delete record...', __FILE__, __LINE__, __METHOD__, 10);
                 if ($user_id > 0) {
                     //Remove this user_id from the user array.
                     $new_user_ids = array_diff((array) $lf->getUser(), (array) $user_id);
                     Debug::Arr($new_user_ids, 'Removing individual users from schedule, remaining users are: ', __FILE__, __LINE__, __METHOD__, 10);
                     if (count($new_user_ids) > 0) {
                         $lf->setUser($new_user_ids);
                     } else {
                         //No users left, delete the entire recurring schedule.
                         Debug::Text('No users left in schedule, removing entire schedule...', __FILE__, __LINE__, __METHOD__, 10);
                         $lf->setDeleted(TRUE);
                     }
                     unset($new_user_ids);
                 } else {
                     $lf->setDeleted(TRUE);
                 }
                 $is_valid = $lf->isValid();
                 if ($is_valid == TRUE) {
                     Debug::Text('Record Deleted...', __FILE__, __LINE__, __METHOD__, 10);
                     $save_result[$key] = $lf->Save();
                     $validator_stats['valid_records']++;
                 }
             }
             if ($is_valid == FALSE) {
                 Debug::Text('Data is Invalid...', __FILE__, __LINE__, __METHOD__, 10);
                 $lf->FailTransaction();
                 //Just rollback this single record, continue on to the rest.
                 if ($primary_validator->isValid() == FALSE) {
                     $validator[$key] = $primary_validator->getErrorsArray();
                 } else {
                     $validator[$key] = $lf->Validator->getErrorsArray();
                 }
             }
             $lf->CommitTransaction();
             $this->getProgressBarObject()->set($this->getAMFMessageID(), $key);
         }
         $this->getProgressBarObject()->stop($this->getAMFMessageID());
         if ($validator_stats['valid_records'] > 0 and $validator_stats['total_records'] == $validator_stats['valid_records']) {
//.........这里部分代码省略.........
开发者ID:alachaum,项目名称:timetrex,代码行数:101,代码来源:APIRecurringScheduleControl.class.php


注:本文中的Validator::getErrorsArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。