public function processRequest($method = 'POST')
 {
     $params = http_build_query($this->urlParams);
     if (w2p_check_url($this->url)) {
         if (function_exists('curl_init')) {
             $ch = curl_init($this->url);
             curl_setopt($ch, CURLOPT_POST, 1);
             curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
             $response = curl_exec($ch);
             curl_close($ch);
         } else {
             /*
              * Thanks to Wez Furlong for the core of the logic for this 
              *   method to POST data via PHP without cURL
              *   http://netevil.org/blog/2006/nov/http-post-from-php-without-curl
              */
             $ctx = stream_context_create($params);
             $fp = @fopen($this->url, 'rb', false, $ctx);
             if (!$fp) {
                 throw new Exception("Problem with {$url}, {$php_errormsg}");
             }
             $response = @stream_get_contents($fp);
             if ($response === false) {
                 throw new Exception("Problem reading data from {$url}, {$php_errormsg}");
             }
         }
         return $response;
     } else {
         //throw an error?
     }
 }
Example #2
0
 public function check()
 {
     $errorArray = array();
     $baseErrorMsg = get_class($this) . '::store-check failed - ';
     if ('' == trim($this->company_name)) {
         $errorArray['company_name'] = $baseErrorMsg . 'company name is not set';
     }
     if ((int) $this->company_owner == 0) {
         $errorArray['company_owner'] = $baseErrorMsg . 'company owner is not set';
     }
     if ('' != $this->company_primary_url && !w2p_check_url($this->company_primary_url)) {
         $errorArray['company_primary_url'] = $baseErrorMsg . 'company primary url is not formatted properly';
     }
     if ('' != $this->company_email && !w2p_check_email($this->company_email)) {
         $errorArray['company_email'] = $baseErrorMsg . 'company email is not formatted properly';
     }
     return $errorArray;
 }
Example #3
0
 public function check()
 {
     global $AppUI;
     $errorArray = array();
     $baseErrorMsg = get_class($this) . '::store-check failed - ';
     $this->task_id = (int) $this->task_id;
     if (is_null($this->task_priority) || !is_numeric((int) $this->task_priority)) {
         $errorArray['task_priority'] = $baseErrorMsg . 'task priority is NULL';
     }
     if ($this->task_name == '') {
         $errorArray['task_name'] = $baseErrorMsg . 'task name is NULL';
     }
     if (is_null($this->task_project) || 0 == (int) $this->task_project) {
         $errorArray['task_project'] = $baseErrorMsg . 'task project is not set';
     }
     //Only check the task dates if the config option "check_task_dates" is on
     if (w2PgetConfig('check_task_dates')) {
         if ($this->task_start_date == '' || $this->task_start_date == '0000-00-00 00:00:00') {
             $errorArray['task_start_date'] = $baseErrorMsg . 'task start date is NULL';
         }
         if ($this->task_end_date == '' || $this->task_end_date == '0000-00-00 00:00:00') {
             $errorArray['task_end_date'] = $baseErrorMsg . 'task end date is NULL';
         }
         if (!isset($errorArray['task_start_date']) && !isset($errorArray['task_end_date'])) {
             $startTimestamp = strtotime($this->task_start_date);
             $endTimestamp = strtotime($this->task_end_date);
             if (60 > abs($endTimestamp - $startTimestamp)) {
                 $endTimestamp = $startTimestamp;
             }
             if ($startTimestamp > $endTimestamp) {
                 $errorArray['bad_date_selection'] = $baseErrorMsg . 'task start date is after task end date';
             }
         }
     }
     // ensure changes to checkboxes are honoured
     $this->task_milestone = (int) $this->task_milestone;
     $this->task_dynamic = (int) $this->task_dynamic;
     $this->task_percent_complete = (int) $this->task_percent_complete;
     $this->task_target_budget = $this->task_target_budget ? $this->task_target_budget : 0.0;
     if (!$this->task_duration || $this->task_milestone) {
         $this->task_duration = '0';
     }
     if ($this->task_milestone) {
         if ($this->task_start_date && $this->task_start_date != '0000-00-00 00:00:00') {
             $this->task_end_date = $this->task_start_date;
         } else {
             $this->task_start_date = $this->task_end_date;
         }
     }
     if (!$this->task_creator) {
         $this->task_creator = $AppUI->user_id;
     }
     if (!$this->task_duration_type) {
         $this->task_duration_type = 1;
     }
     if (!$this->task_related_url) {
         $this->task_related_url = '';
     }
     if (!$this->task_notify) {
         $this->task_notify = 0;
     }
     if ('' != $this->task_related_url && !w2p_check_url($this->task_related_url)) {
         $errorArray['task_related_url'] = $baseErrorMsg . 'task related url is not formatted properly';
     }
     /*
      * Check for bad or circular task relationships (dep or child-parent).
      * These checks are definately not exhaustive it is still quite possible
      * to get things in a knot.
      * Note: some of these checks may be problematic and might have to be removed
      */
     static $addedit;
     if (!isset($addedit)) {
         $addedit = w2PgetParam($_POST, 'dosql', '') == 'do_task_aed' ? true : false;
     }
     $this_dependencies = array();
     /*
      * If we are called from addedit then we want to use the incoming
      * list of dependencies and attempt to stop bad deps from being created
      */
     if ($addedit) {
         $hdependencies = w2PgetParam($_POST, 'hdependencies', '0');
         if ($hdependencies) {
             $this_dependencies = explode(',', $hdependencies);
         }
     } else {
         $this_dependencies = explode(',', $this->getDependencies());
     }
     // Set to false for recursive updateDynamic calls etc.
     $addedit = false;
     // Have deps
     if (array_sum($this_dependencies)) {
         if ($this->task_dynamic == 1) {
             return array('BadDep_DynNoDep');
         }
         $this_dependents = $this->task_id ? explode(',', $this->dependentTasks()) : array();
         $more_dependents = array();
         // If the dependents' have parents add them to list of dependents
         foreach ($this_dependents as $dependent) {
             $dependent_task = new CTask();
             $dependent_task->load($dependent);
             if ($dependent_task->task_id != $dependent_task->task_parent) {
                 $more_dependents = explode(',', $this->dependentTasks($dependent_task->task_parent));
             }
         }
         $this_dependents = array_merge($this_dependents, $more_dependents);
         // Task dependencies can not be dependent on this task
         $intersect = array_intersect($this_dependencies, $this_dependents);
         if (array_sum($intersect)) {
             $ids = '(' . implode(',', $intersect) . ')';
             return array('BadDep_CircularDep', $ids);
         }
     }
     // Has a parent
     if ($this->task_id && $this->task_parent && $this->task_id != $this->task_parent) {
         $this_children = $this->getChildren();
         $this_parent = new CTask();
         $this_parent->load($this->task_parent);
         $parents_dependents = explode(',', $this_parent->dependentTasks());
         if (in_array($this_parent->task_id, $this_dependencies)) {
             return array('BadDep_CannotDependOnParent');
         }
         // Task parent cannot be child of this task
         if (in_array($this_parent->task_id, $this_children)) {
             return array('BadParent_CircularParent');
         }
         if ($this_parent->task_parent != $this_parent->task_id) {
             // ... or parent's parent, cannot be child of this task. Could go on ...
             if (in_array($this_parent->task_parent, $this_children)) {
                 return array('BadParent_CircularGrandParent', '(' . $this_parent->task_parent . ')');
             }
             // parent's parent cannot be one of this task's dependencies
             if (in_array($this_parent->task_parent, $this_dependencies)) {
                 return array('BadDep_CircularGrandParent', '(' . $this_parent->task_parent . ')');
             }
         }
         // grand parent
         if ($this_parent->task_dynamic == 1) {
             $intersect = array_intersect($this_dependencies, $parents_dependents);
             if (array_sum($intersect)) {
                 $ids = '(' . implode(',', $intersect) . ')';
                 return array('BadDep_CircularDepOnParentDependent', $ids);
             }
         }
         if ($this->task_dynamic == 1) {
             // then task's children can not be dependent on parent
             $intersect = array_intersect($this_children, $parents_dependents);
             if (array_sum($intersect)) {
                 return array('BadParent_ChildDepOnParent');
             }
         }
     }
     // parent
     return $errorArray;
 }
 public function check()
 {
     $errorArray = array();
     $baseErrorMsg = get_class($this) . '::store-check failed - ';
     if ('' == $this->project_name) {
         $errorArray['project_name'] = $baseErrorMsg . 'project name is not set';
     }
     if ('' == $this->project_short_name) {
         $errorArray['project_short_name'] = $baseErrorMsg . 'project short name is not set';
     }
     if (0 == (int) $this->project_company) {
         $errorArray['project_company'] = $baseErrorMsg . 'project company is not set';
     }
     if (0 == (int) $this->project_owner) {
         $errorArray['project_owner'] = $baseErrorMsg . 'project owner is not set';
     }
     if (0 == (int) $this->project_creator) {
         $errorArray['project_creator'] = $baseErrorMsg . 'project creator is not set';
     }
     if (!is_int($this->project_priority) && '' == $this->project_priority) {
         $errorArray['project_priority'] = $baseErrorMsg . 'project priority is not set';
     }
     if ('' == $this->project_color_identifier) {
         $errorArray['project_color_identifier'] = $baseErrorMsg . 'project color identifier is not set';
     }
     if (!is_int($this->project_type) && '' == $this->project_type) {
         $errorArray['project_type'] = $baseErrorMsg . 'project type is not set';
     }
     if (!is_int($this->project_status) && '' == $this->project_status) {
         $errorArray['project_status'] = $baseErrorMsg . 'project status is not set';
     }
     if ('' != $this->project_url && !w2p_check_url($this->project_url)) {
         $errorArray['project_url'] = $baseErrorMsg . 'project url is not formatted properly';
     }
     if ('' != $this->project_demo_url && !w2p_check_url($this->project_demo_url)) {
         $errorArray['project_demo_url'] = $baseErrorMsg . 'project demo url is not formatted properly';
     }
     $this->_error = $errorArray;
     return $errorArray;
 }
Example #5
0
 public function check()
 {
     // ensure the integrity of some variables
     $errorArray = array();
     $baseErrorMsg = get_class($this) . '::store-check failed - ';
     if ('' == trim($this->link_name)) {
         $errorArray['link_name'] = $baseErrorMsg . 'link name is not set';
     }
     if ('' == trim($this->link_url)) {
         $errorArray['link_url'] = $baseErrorMsg . 'link url is not set';
     }
     if ('' != $this->link_url && !w2p_check_url($this->link_url)) {
         $errorArray['link_url'] = $baseErrorMsg . 'link url is not formatted properly';
     }
     if (0 == (int) $this->link_owner) {
         $errorArray['link_owner'] = $baseErrorMsg . 'link owner is not set';
     }
     return $errorArray;
 }
 public function test_w2p_check_url()
 {
     $this->assertTrue(w2p_check_url('http://web2project.net'));
     $this->assertTrue(w2p_check_url('http://bugs.web2project.net'));
     $this->assertTrue(w2p_check_url('web2project.net'));
     $this->assertTrue(w2p_check_url('http://forums.web2project.net/'));
     $this->assertTrue(w2p_check_url('http://wiki.web2project.net/'));
     $this->assertTrue(w2p_check_url('http://wiki.web2project.net/index.php?title=Main_Page'));
     $this->assertTrue(w2p_check_url('wiki.web2project.net/index.php?title=Category:Frequently_Asked_Questions'));
     //$this->assertFalse(w2p_check_url('httpweb2project.net'));
     //$this->assertFalse(w2p_check_url('http://web2project'));
     //$this->assertFalse(w2p_check_url('http://.net'));
 }
Example #7
0
 public function test_w2p_check_url()
 {
     $this->assertTrue(w2p_check_url('http://web2project.net'));
     $this->assertTrue(w2p_check_url('http://bugs.web2project.net'));
     $this->assertTrue(w2p_check_url('web2project.net'));
     $this->assertFalse(w2p_check_url('httpweb2project.net'));
     $this->assertFalse(w2p_check_url('http://web2project'));
     $this->assertFalse(w2p_check_url('http://.net'));
 }
 public function check()
 {
     $errorArray = array();
     $baseErrorMsg = get_class($this) . '::store-check failed - ';
     if (0 == (int) $this->dept_company) {
         $errorArray['dept_company'] = $baseErrorMsg . 'department company is not set';
     }
     if ('' == trim($this->dept_name)) {
         $errorArray['dept_name'] = $baseErrorMsg . 'department name is not set';
     }
     if (0 != $this->dept_id && $this->dept_id == $this->dept_parent) {
         $errorArray['parentError'] = $baseErrorMsg . 'a department cannot be its own parent';
     }
     if (0 == (int) $this->dept_owner) {
         $errorArray['dept_owner'] = $baseErrorMsg . 'department owner is not set';
     }
     if ('' != $this->dept_url && !w2p_check_url($this->dept_url)) {
         $errorArray['dept_url'] = $baseErrorMsg . 'department url is not formatted properly';
     }
     $this->_error = $errorArray;
     return $errorArray;
 }
Example #9
0
 public function check()
 {
     $errorArray = array();
     $baseErrorMsg = get_class($this) . '::store-check failed - ';
     if ('' != $this->contact_url && !w2p_check_url($this->contact_url)) {
         $errorArray['contact_url'] = $baseErrorMsg . 'contact url is not formatted properly';
     }
     if ('' != $this->contact_email && !w2p_check_email($this->contact_email)) {
         $errorArray['contact_email'] = $baseErrorMsg . 'contact email is not formatted properly';
     }
     if ('' != $this->contact_email2 && !w2p_check_email($this->contact_email2)) {
         $errorArray['contact_email2'] = $baseErrorMsg . 'contact email2 is not formatted properly';
     }
     return $errorArray;
 }