Example #1
0
 public function test_strip_unwated_description_chars()
 {
     $cases = array("Description with <div>div</div>" => "Description with div", "<p style='font-size:300%;'>Big text</p>" => "Big text");
     $failed = FALSE;
     foreach ($cases as $test => $expected) {
         $actual = Project::strip_unwated_description_chars($test);
         if ($actual != $expected) {
             echo "FAIL: '{$test}' => '{$actual}'   EXPECTED:   '{$expected}'\n";
             $failed = TRUE;
         } else {
             echo "PASS: '******'\n";
         }
     }
     $this->assertTrue(!$failed);
 }
Example #2
0
 /**
  * Set description.
  */
 public function set_description($unsafe_desc)
 {
     // Convert to url name from unsafe name, to get an as good url name as possible
     $this->description = Project::strip_unwated_description_chars($unsafe_desc);
 }
Example #3
0
 /**
  * Sets project description. Returns string that was written to
  * the database.
  */
 public static function set_project_description($project_id, $unsafe_desc)
 {
     if (!($project_id && is_int($project_id) && $project_id > 0 && $unsafe_desc && is_string($unsafe_desc)) || !Sql::project_owner_for_id_is_logged_in($project_id)) {
         return NULL;
     }
     $desc = Project::strip_unwated_description_chars($unsafe_desc);
     $query = new SqlQuery("UPDATE Projects SET project_description='%s' WHERE project_id='%s' LIMIT 1", $desc, $project_id);
     if (!$query->was_successful()) {
         $desc = NULL;
     }
     return $desc;
 }