コード例 #1
0
 public function validate($value)
 {
     $is_valid = true;
     if ($value) {
         $rule = new Rule_Date();
         $is_valid = $rule->isValid($value);
         if (!$is_valid) {
             $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('plugin_tracker_common_artifact', 'error_date_value', array($this->field->getLabel())));
         }
     }
     return $is_valid;
 }
コード例 #2
0
ファイル: IM.class.php プロジェクト: pombredanne/tuleap
 function request()
 {
     $request =& HTTPRequest::instance();
     $group_id = $request->get('group_id');
     $user = UserManager::instance()->getCurrentUser();
     switch ($request->get('action')) {
         case 'synchronize_all':
             if ($user->isSuperUser()) {
                 $this->action = 'synchronize_all';
                 $this->view = 'codendi_im_admin';
             } else {
                 $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('global', 'perm_denied'));
             }
             break;
         case 'synchronize_muc_only':
             if ($user->isSuperUser()) {
                 $this->action = 'synchronize_muc_only';
                 $this->view = 'codendi_im_admin';
             } else {
                 $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('global', 'perm_denied'));
             }
             break;
         case 'synchronize_grp_only':
             if ($user->isSuperUser()) {
                 $this->action = 'synchronize_grp_only';
                 $this->view = 'codendi_im_admin';
             } else {
                 $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('global', 'perm_denied'));
             }
             break;
         case 'synchronize_muc_and_grp':
             if ($user->isSuperUser()) {
                 $this->action = 'synchronize_muc_and_grp';
                 $this->view = 'codendi_im_admin';
             } else {
                 $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('global', 'perm_denied'));
             }
             break;
         case 'get_presence':
             $this->view = 'get_presence';
             break;
         case 'codendi_im_admin':
             if ($user->isSuperUser()) {
                 $this->view = 'codendi_im_admin';
             } else {
                 $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('global', 'perm_denied'));
             }
             break;
         case 'viewchatlog':
             if ($user->isMember($group_id)) {
                 $chat_log = $request->get('chat_log');
                 if (strlen($chat_log) != 8 || !is_numeric($chat_log)) {
                     $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('plugin_im', 'reference_format_error', array($chat_log)));
                 }
                 $this->view = 'ref_muc_logs';
             } else {
                 $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('global', 'perm_denied'));
             }
             break;
         case 'muc_logs':
             if ($user->isMember($group_id)) {
                 $any = $GLOBALS['Language']->getText('global', 'any');
                 $start_date = $request->get('log_start_date');
                 if ($start_date != $any && $start_date != '') {
                     $r = new Rule_Date();
                     if (!$r->isValid($start_date)) {
                         $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('plugin_im', 'date_format_error', array($start_date)));
                     }
                 }
                 // else date is '' or any
                 $end_date = $request->get('log_end_date');
                 if ($end_date != $any && $end_date != '') {
                     $r = new Rule_Date();
                     if (!$r->isValid($end_date)) {
                         $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('plugin_im', 'date_format_error', array($end_date)));
                     }
                 }
                 // else date is '' or any
                 if ($request->get('type') == 'export') {
                     $this->view = 'export_muc_logs';
                 } else {
                     $this->view = 'muc_logs';
                 }
             } else {
                 $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('global', 'perm_denied'));
             }
             break;
         default:
             if ($group_id) {
                 $pm = ProjectManager::instance();
                 $project = $pm->getProject($group_id);
                 if ($project->usesService('IM')) {
                     if ($user->isMember($group_id)) {
                         $this->view = 'chat_room';
                     } else {
                         $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('global', 'perm_denied'));
                     }
                 } else {
                     $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('plugin_im_admin', 'service_not_used'));
                 }
             } else {
                 if ($user->isSuperUser()) {
                     $this->view = 'codendi_im_admin';
                 } else {
                     $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('global', 'perm_denied'));
                 }
             }
             break;
     }
 }
コード例 #3
0
ファイル: Rule_DateTest.php プロジェクト: pombredanne/tuleap
 function testLeapYear()
 {
     $r = new Rule_Date();
     $this->assertFalse($r->isValid('2001-2-29'));
     $this->assertTrue($r->isValid('2004-2-29'));
 }
コード例 #4
0
 /**
  * Validate a value
  *
  * @param Tracker_Artifact $artifact The artifact 
  * @param mixed            $value    data coming from the request. May be string or array. 
  *
  * @return bool true if the value is considered ok
  */
 protected function validate(Tracker_Artifact $artifact, $value)
 {
     $is_valid = true;
     if ($value) {
         $r = new Rule_Date();
         if (!($is_valid = $r->isValid($value))) {
             $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('plugin_tracker_common_artifact', 'error_date_value', array($this->getLabel())));
         }
     }
     return $is_valid;
 }