Example #1
0
 public function executeSaveNew()
 {
     $project = new Project();
     $culture = $this->getUser()->getCulture();
     // TODO: Implement multiple owners / project leads, if necessary
     $project->setCreatedBy($this->getUser()->getGuardUser()->getId());
     $project->setOwnerId($this->getUser()->getGuardUser()->getId());
     $project->setDepartmentId($this->getRequestParameter('department_id') ? $this->getRequestParameter('department_id') : null);
     $project->setTitle($this->getRequestParameter('title'));
     $project->setDescription($this->getRequestParameter('description'));
     $project->setNotes($this->getRequestParameter('notes'));
     $project->setKeywords($this->getRequestParameter('tags_as_text'));
     if ($this->getRequestParameter('begin')) {
         list($d, $m, $y) = sfI18N::getDateForCulture($this->getRequestParameter('begin'), $this->getUser()->getCulture());
         $project->setBegin("{$y}-{$m}-{$d}");
     }
     if ($this->getRequestParameter('finish')) {
         list($d, $m, $y) = sfI18N::getDateForCulture($this->getRequestParameter('finish'), $this->getUser()->getCulture());
         $project->setFinish("{$y}-{$m}-{$d}");
     }
     $this->logMessage('Dates Saved');
     $project->setCampusId($this->getRequestParameter('campus'));
     $project->setPublished($this->getRequestParameter('published', 0));
     $project->save();
     $this->logMessage('Project Saved');
     $project->createDefaultPermissions();
     return $this->redirect('project/awaitApproval');
 }
Example #2
0
     }
     // check file extension
     foreach ($files as $file) {
         $file = trim($file);
         $tokens = explode(".", $file);
         $extension = array_pop($tokens);
         if (!in_array(strtolower($extension), array('jpg', 'png', 'gif', 'zip'))) {
             Message::register(new Message(Message::DANGER, i18n(array("en" => "Only file with extension jpg,png,gif,zip is allowed. Please restrict your files with these types.", "zh" => "上传文件仅支持jpg,png,gif,zip,请检查您的上传文件"))));
             $error_flag = true;
             break;
         }
     }
 }
 /// proceed submission
 // proceed for $title
 $object->setTitle($title);
 // proceed for $password
 $object->setPassword($password);
 // proceed for $email
 $object->setEmail($email);
 // proceed for $description_en
 $object->setDescriptionEn($description_en);
 // proceed for $description_zh
 $object->setDescriptionZh($description_zh);
 // proceed for $active
 $object->setActive($active);
 // proceed for $price
 if (!empty($price)) {
     $object->setPrice($price);
 }
 // proceed for $images
Example #3
0
 public static function project_new()
 {
     $postVars = array();
     foreach ($_POST['newProjectContainer'] as $name => $value) {
         if (isset($value['value'])) {
             $postVars[$name] = $value['value'];
         }
     }
     //
     // Check for mandatory attributes
     //
     if (!isset($postVars['title']) || empty($postVars['title']) || !isset($postVars['scmConnectorType']) || empty($postVars['scmConnectorType']) || !isset($postVars['scmRemoteRepository']) || empty($postVars['scmRemoteRepository'])) {
         //
         // TODO: Error notification!!!
         //
         SystemEvent::raise(SystemEvent::DEBUG, "Project creation failed, required attributes were empty.", __METHOD__);
         echo json_encode(array('success' => false, 'error' => 'Missing required attributes. Make sure all attributes not marked as optional are filled.'));
         exit;
     } else {
         $GLOBALS['project'] = null;
         $project = new Project();
         $project->setTitle($postVars['title']);
         $project->setReleaseLabel($postVars['releaseLabel']);
         $project->setScmConnectorType($postVars['scmConnectorType']);
         $project->setScmRemoteRepository($postVars['scmRemoteRepository']);
         $project->setScmUsername($postVars['scmUsername']);
         $project->setScmPassword($postVars['scmPassword']);
         $project->addToUsers($GLOBALS['user'], Access::OWNER);
         if (!$project->init()) {
             SystemEvent::raise(SystemEvent::ERROR, "Could not initialize project. Try again later.", __METHOD__);
             echo json_encode(array('success' => false, 'error' => 'The project was created but could not be initialized. Please check the logs and/or try the first build manually.'));
             exit;
         }
         $GLOBALS['project'] = $project;
         $GLOBALS['project']->log("Project created.", $GLOBALS['user']->getUsername());
         echo json_encode(array('success' => true, 'error' => 'Project successfully created, taking you back to your dashboard. Stand by...'));
         exit;
     }
 }
Example #4
0
 public function save()
 {
     // yo thau ma project save huna aaucha
     // yei bata feri "index.php" ma falne jun chai profile ma jancha
     $proj = new Project();
     if (isset($_POST['single_date']) && $_POST['single_date'] != "") {
         $proj->setStart_date($_POST['single_date']);
     } else {
         if (isset($_POST['start_date'])) {
             $proj->setStart_date($_POST['start_date']);
             if (isset($_POST['end_date'])) {
                 $proj->setEnd_date($_POST['end_date']);
             } else {
                 $proj->setEnd_date("");
             }
         } else {
             $proj->setStart_date("");
             $proj->setEnd_date("");
         }
     }
     $proj->setTitle($_POST['project_title']);
     $proj->setObjectives($_POST['project_objectives']);
     $proj->setShortdes($_POST['short_desc']);
     $proj->setLocation($_POST['location']);
     if (isset($_POST['amount'])) {
         $proj->setBudget($_POST['amount']);
     } else {
         $proj->setBudget(NULL);
     }
     if (isset($_POST['requirement1'])) {
         $proj->setRequirement($_POST['requirement1']);
     } else {
         $proj->setRequirement("");
     }
     if (isset($_POST['requirement2'])) {
         $proj->setRequirement($_POST['requirement2']);
     }
     if (isset($_POST['requirement3'])) {
         $proj->setRequirement($_POST['requirement3']);
     }
     if (isset($_POST['requirement4'])) {
         $proj->setRequirement($_POST['requirement4']);
     }
     if (isset($_POST['requirement5'])) {
         $proj->setRequirement($_POST['requirement5']);
     }
     if (isset($_POST['cb_volunteer'])) {
         if (isset($_POST['number_volunteer'])) {
             $proj->setVolunteer($_POST['number_volunteer']);
         } else {
             $proj->setVolunteer(1);
         }
     } else {
         $proj->setVolunteer(0);
     }
     if (isset($_POST['cb_otherorg'])) {
         if (isset($_POST['organization1'])) {
             $proj->setOrganization($_POST['organization1']);
         } else {
             $proj->setOrganization("");
         }
         if (isset($_POST['organization2'])) {
             $proj->setOrganization($_POST['organization2']);
         }
         if (isset($_POST['organization3'])) {
             $proj->setOrganization($_POST['organization3']);
         }
         if (isset($_POST['organization4'])) {
             $proj->setOrganization($_POST['organization4']);
         }
         if (isset($_POST['organization5'])) {
             $proj->setOrganization($_POST['organization5']);
         }
     } else {
         $proj->setOrganization("");
     }
     if (isset($_FILES['banner_image'])) {
         if ($_FILES['banner_image']['name'] != "") {
             $filename = $_FILES['banner_image']['name'];
             $path = ROOT_PATH . "/profile/project_image/";
             move_uploaded_file($_FILES['banner_image']['tmp_name'], $path . $filename);
             $savepath = BASE_URL . "/profile/project_image/";
             $proj->setBanner_image($savepath . $filename);
         } else {
             $filename = "default.jpg";
             $savepath = BASE_URL . "/profile/project_image/";
             $proj->setBanner_image($savepath . $filename);
         }
     } else {
         $savepath = BASE_URL . "/profile/project_image/";
         $proj->setBanner_image($savepath . "default.jpg");
     }
     if (isset($_FILES['project_proposal'])) {
         if ($_FILES['project_proposal']['name'] != "") {
             $filename = $_FILES['project_proposal']['name'];
             $path = ROOT_PATH . "/profile/project_proposal/";
             move_uploaded_file($_FILES['project_proposal']['tmp_name'], $path . $filename);
             $savepath = BASE_URL . "/profile/project_proposal/";
             $proj->setProject_proposal($savepath . $filename);
         } else {
             $filename = "default.docx";
             $savepath = BASE_URL . "/profile/project_proposal/";
             $proj->setProject_proposal($savepath . $filename);
         }
     } else {
         $savepath = BASE_URL . "/profile/project_proposal/";
         $proj->setProject_proposal($savepath . "default.docx");
     }
     if (isset($_POST['project_video'])) {
         $string = $_POST['project_video'];
         $search = '#(.*?)(?:href="https?://)?(?:www\\.)?(?:youtu\\.be/|youtube\\.com(?:/embed/|/v/|/watch?.*?v=))([\\w\\-]{10,12}).*#x';
         $replace = 'http:/utube.com/embed/$2';
         $url = preg_replace($search, $replace, $string);
         $proj->setVideourl($url);
     } else {
         $proj->setVideourl("");
     }
     if (isset($_POST['details'])) {
         $proj->setDetail($_POST['details']);
     } else {
         $proj->setDetail("");
     }
     $proj->setStatus(1);
     $id = $this->projectrepository->insert($proj);
 }
Example #5
0
 public function approve()
 {
     if (!$this->getIsApproved()) {
         $this->setIsApproved(true);
         $project = new Project();
         $project->setCreatedBy($this->getCreatedBy());
         $project->setOwnerId($this->getOwnerId());
         $project->setDepartmentId($this->getDepartmentId());
         $project->setCampusId($this->getCampusId());
         $project->setTitle($this->getTitle());
         $project->setDescription($this->getDescription());
         $project->setNotes($this->getNotes());
         $project->setBegin($this->getBegin());
         $project->setFinish($this->getFinish());
         $project->setMainForm('default');
         $project->setPublished(true);
         $project->setIsApproved(true);
         $project->save();
     }
 }
 public function get_by_id($project_id)
 {
     $proj = null;
     $this->database->connect();
     $sql = "SELECT * FROM projects WHERE project_id=?";
     //prepare the statement
     $statement = $this->database->initialize($sql);
     //Bind the parameters
     $statement->bind_param("i", $project_id);
     //Execute the above statement
     $statement->execute();
     //Bind the result
     $statement->bind_result($project_id, $start_date, $end_date, $title, $objectives, $short_desc, $location, $budget, $volunteer, $banner_image, $project_proposal, $video_url, $detail, $status, $u_id);
     while ($statement->fetch()) {
         $proj = new Project();
         $proj->setProject_id($project_id);
         $proj->setStart_date($start_date);
         $proj->setEnd_date($end_date);
         $proj->setTitle($title);
         $proj->setObjectives($objectives);
         $proj->setShortdes($short_desc);
         $proj->setLocation($location);
         $proj->setBudget($budget);
         $proj->setVolunteer($volunteer);
         $proj->setBanner_image($banner_image);
         $proj->setProject_proposal($project_proposal);
         $proj->setVideourl($video_url);
         $proj->setDetail($detail);
         $proj->setStatus($status);
         $proj->setUid($u_id);
     }
     //Close Connection
     $this->database->close();
     return $proj;
 }
Example #7
0
 /**
  *
  * @param unknown_type $rs
  */
 private static function &_getObject(Resultset $rs, array $options = array())
 {
     isset($options['loadUsers']) ?: ($options['loadUsers'] = true);
     $ret = new Project();
     $ret->setAvatar($rs->getAvatar());
     $ret->setScmConnectorType($rs->getScmConnectorType());
     $ret->setScmRemoteRepository($rs->getScmRemoteRepository());
     $ret->setScmUsername($rs->getScmUsername());
     $ret->setScmPassword($rs->getScmPassword());
     $ret->setScmCheckChangesTimeout($rs->getScmCheckChangesTimeout());
     $ret->setWorkDir($rs->getWorkDir());
     $ret->setReleaseLabel($rs->getReleaseLabel());
     $ret->setDateCreation($rs->getDateCreation());
     $ret->setDateCheckedForChanges($rs->getDateCheckedForChanges());
     $ret->setDescription($rs->getDescription());
     $ret->setId($rs->getId());
     $specialTasks = @unserialize($rs->getSpecialTasks());
     if ($specialTasks === false) {
         $specialTasks = array();
     }
     $ret->setSpecialTasks($specialTasks);
     $ret->setStatsNumBuilds($rs->getStatsNumBuilds());
     $ret->setStatus($rs->getStatus());
     $ret->setTitle($rs->getTitle());
     $ret->setVisits($rs->getVisits());
     $ret->setOptionReleasePackage($rs->getOptionReleasePackage());
     $ret->setScmEnvVars($rs->getScmEnvVars());
     //
     // Builders
     //
     //
     // The following is a workaround on the fact that the translation of this
     // serialized object to the database gets all broken, due to the fact of PHP
     // introducing NULL bytes around the '*' that is prepended before protected
     // variable members, in the serialized mode. This method replaces those
     // problematic NULL bytes with an identifier string '~~NULL_BYTE~~',
     // rendering serialization and unserialization of these specific kinds of
     // object safe. Credits to travis@travishegner.com on:
     // http://pt.php.net/manual/en/function.serialize.php#96504
     //
     $unsafeSerializedIntegrationBuilder = str_replace(CINTIENT_NULL_BYTE_TOKEN, "", $rs->getIntegrationBuilder());
     if (($integrationBuilder = unserialize($unsafeSerializedIntegrationBuilder)) === false) {
         SystemEvent::raise(SystemEvent::ERROR, "Couldn't unserialize integration builder for this project [PID={$ret->getId()}]");
         $integrationBuilder = new Build_BuilderElement_Project();
     }
     $ret->setIntegrationBuilder($integrationBuilder);
     $unsafeSerializedDeploymentBuilder = str_replace(CINTIENT_NULL_BYTE_TOKEN, "", $rs->getDeploymentBuilder());
     if (($deploymentBuilder = unserialize($unsafeSerializedDeploymentBuilder)) === false) {
         SystemEvent::raise(SystemEvent::ERROR, "Couldn't unserialize deployment builder for this project [PID={$ret->getId()}]");
         $deploymentBuilder = new Build_BuilderElement_Project();
     }
     $ret->setDeploymentBuilder($deploymentBuilder);
     if ($options['loadUsers']) {
         $ret->loadUsers();
     }
     $ret->resetSignature();
     return $ret;
 }