Пример #1
0
 public function getBranch()
 {
     $c = new Criteria();
     $c->addJoin(BranchPeer::ID, UserPeer::BRANCH_ID);
     $c->add(UserPeer::ID, $this->getId());
     return $branch = BranchPeer::doSelectOne($c);
 }
Пример #2
0
 /**
  * @param sfWebRequest $request
  * @return void
  */
 public function execute($request)
 {
     $branch = BranchPeer::retrieveByPK($request->getParameter('branch'));
     $this->forward404Unless($branch, 'Branch Not Found');
     $oldtStatus = $branch->getStatus();
     $branch->setIsBlacklisted(true)->setReviewRequest(false)->save();
     Branch::saveAction($this->getUser()->getId(), $branch->getRepositoryId(), $branch->getId(), $oldtStatus, $branch->getStatus());
     $this->getResponse()->setContentType('application/json');
     return $this->renderText(json_encode(array('status' => 'blacklisted')));
 }
 /**
  * @param sfWebRequest $request
  * @return void
  */
 public function execute($request)
 {
     $repository = RepositoryPeer::retrieveByPK($request->getParameter('repository'));
     $this->forward404Unless($repository, "Repository Not Found");
     $branches = BranchQuery::create()->filterByRepositoryId($repository->getId())->filterByIsBlacklisted(0)->find();
     foreach ($branches as $branch) {
         BranchPeer::synchronize($this->gitCommand, $repository, $branch, true);
     }
     $this->redirect('default/branchList?repository=' . $repository->getId());
 }
Пример #4
0
 /**
  * @param sfWebRequest $request
  * @return void
  */
 public function execute($request)
 {
     $this->file = FilePeer::retrieveByPK($request->getParameter('file'));
     $this->forward404Unless($this->file, "File not found");
     $this->branch = BranchPeer::retrieveByPK($this->file->getBranchId());
     $this->forward404Unless($this->branch, "Branch not found");
     $this->repository = RepositoryPeer::retrieveByPK($this->branch->getRepositoryId());
     $this->forward404Unless($this->repository, "Repository not found");
     $this->fileContent = $this->gitCommand->getShowFile($this->repository->getGitDir(), $this->file->getLastChangeCommit(), $this->file->getFilename());
     $this->fileExtension = pathinfo($this->file->getFilename(), PATHINFO_EXTENSION);
 }
Пример #5
0
 /**
  * @static
  * @param int $userId
  * @param int $repositoryId
  * @param int $branchId
  * @param int $oldStatus
  * @param int $newStatus
  * @param string $message
  * @return int
  */
 public static function saveAction($userId, $repositoryId, $branchId, $oldStatus, $newStatus, $message = 'status was changed from <strong>%s</strong> to <strong>%s</strong>')
 {
     if ($oldStatus === $newStatus) {
         return 0;
     }
     $branch = BranchQuery::create()->filterById($branchId)->findOne();
     if (!$branch) {
         return false;
     }
     $statusAction = new StatusAction();
     return $statusAction->setUserId($userId)->setRepositoryId($repositoryId)->setBranchId($branchId)->setOldStatus($oldStatus)->setNewStatus($newStatus)->setMessage(sprintf($message, BranchPeer::getLabelStatus($oldStatus), BranchPeer::getLabelStatus($newStatus)))->save();
 }
Пример #6
0
 public function executeAdvancesearch()
 {
     $this->clearattrib();
     $c = new Criteria();
     $c->addAscendingOrderByColumn('name');
     $branches = BranchPeer::doSelect($c);
     $options = array();
     $options[] = 'Select';
     foreach ($branches as $branch) {
         $options[$branch->getId()] = $branch->getName();
     }
     $this->broptions = $options;
     //Year of graduation
     $options = array();
     $options[] = 'Select';
     for ($i = sfConfig::get('app_year_start'); $i <= sfConfig::get('app_year_end'); $i++) {
         $options[$i] = $i;
     }
     $this->yroptions = $options;
     //Chapter(s) affiliation
     $c = new Criteria();
     $c->addAscendingOrderByColumn('name');
     $chapters = ChapterPeer::doSelect($c);
     $options = array();
     $options[] = 'Select';
     foreach ($chapters as $chapter) {
         $options[$chapter->getId()] = $chapter->getName();
     }
     $this->choptions = $options;
     //User type
     $options = array();
     $options[0] = sfConfig::get('app_usertype_0');
     $options[1] = sfConfig::get('app_usertype_1');
     $options[2] = sfConfig::get('app_usertype_2');
     $this->useroptions = $options;
     //Country
     $c = new Criteria();
     $c->addAscendingOrderByColumn('name');
     $countries = CountryPeer::doSelect($c);
     $options = array();
     $options[] = 'Select';
     foreach ($countries as $country) {
         $options[$country->getId()] = $country->getName();
         //if($country->getName() === 'India'){
         //$this->countryselected = $country->getId();
         //}
     }
     $this->countryoptions = $options;
     $c = new Criteria();
     $this->worktype = WorktypePeer::doSelect($c);
 }
Пример #7
0
 /**
  * @param sfWebRequest $request
  * @return void
  */
 public function execute($request)
 {
     $projectId = $request->getParameter('project_id');
     $baseBranchName = $request->getParameter('base_branch');
     $branchName = $request->getParameter('branch');
     $commit = (string) $request->getParameter('commit');
     // Last commit
     $result = array();
     file_put_contents(sprintf("%s/api.log", sfConfig::get('sf_log_dir')), sprintf("%s [%s] set review = projectId : %s - baseBranchName : %s - branchName : %s - commit : %s\n", date('d/m/Y H:i:s'), $_SERVER['REMOTE_ADDR'], $projectId, $baseBranchName, $branchName, $commit), FILE_APPEND);
     $repository = RepositoryQuery::create()->filterById($projectId)->findOne();
     if ($repository) {
         $branch = BranchQuery::create()->filterByRepositoryId($repository->getId())->filterByName($branchName)->findOne();
         if (!$branch) {
             $branch = new Branch();
             $branch->setName($branchName)->setRepositoryId($repository->getId())->setBaseBranchName($baseBranchName)->save();
         }
         if ($branch->getBaseBranchName() != $baseBranchName) {
             $branch->setBaseBranchName($baseBranchName)->save();
         }
         if (($nbFiles = BranchPeer::synchronize($this->gitCommand, $repository, $branch)) != 0) {
             $result['message'] = sprintf("Your branch '%s' has too many files : %s (max : %s)", $branch->__toString(), $nbFiles, sfConfig::get('app_max_number_of_files_to_review', 4096));
             $this->getResponse()->setStatusCode('500');
         } elseif (!$branch->isDeleted()) {
             if (strlen($commit) === 40) {
                 if (!$this->gitCommand->commitIsInHistory($repository->getGitDir(), $branch->getCommitStatusChanged(), $commit)) {
                     $result['message'] = sprintf("Review has been %sengaged [old status : %s]", $branch->getReviewRequest() ? 're' : '', BranchPeer::getLabelStatus($branch->getStatus()));
                     $branch->setReviewRequest(1)->setStatus(BranchPeer::A_TRAITER)->setIsBlacklisted(0)->save();
                     $this->getResponse()->setStatusCode('201');
                     $this->dispatcher->notify(new sfEvent($this, 'notification.review-request', array('project-id' => $branch->getRepositoryId(), 'object' => $branch)));
                 } else {
                     $result['message'] = sprintf("Commit already used : '%s'", $commit);
                     $this->getResponse()->setStatusCode('200');
                 }
             } else {
                 $result['message'] = sprintf("No valid commit '%s'", $commit);
                 $this->getResponse()->setStatusCode('422');
             }
         } else {
             $result['message'] = sprintf("Unknown branch '%s' in project '%s'", $branchName, $repository->getName());
             $this->getResponse()->setStatusCode('404');
         }
     } else {
         $result['message'] = sprintf("No valid project '%s'", $projectId);
         $this->getResponse()->setStatusCode('400');
     }
     $this->getResponse()->setContentType('application/json');
     return $this->renderText(json_encode($result));
 }
Пример #8
0
 /**
  * @param sfWebRequest $request
  * @return void
  */
 public function execute($request)
 {
     $projectId = $request->getParameter('project_id');
     $result = array();
     file_put_contents(sprintf("%s/api.log", sfConfig::get('sf_log_dir')), sprintf("%s [%s] clean project = projectId : %s\n", date('d/m/Y H:i:s'), $_SERVER['REMOTE_ADDR'], $projectId), FILE_APPEND);
     $repository = RepositoryQuery::create()->filterById($projectId)->findOne();
     if ($repository) {
         $branches = BranchQuery::create()->filterByRepositoryId($repository->getId())->find();
         if ($branches) {
             foreach ($branches as $branch) {
                 BranchPeer::synchronize($this->gitCommand, $repository, $branch, true);
             }
         }
         $this->getResponse()->setStatusCode('200');
     } else {
         $result['message'] = sprintf("No valid project '%s'", $projectId);
         $this->getResponse()->setStatusCode('400');
     }
     $this->getResponse()->setContentType('application/json');
     return $this->renderText(json_encode($result));
 }
Пример #9
0
 /**
  * @param sfWebRequest $request
  * @return void
  */
 public function execute($request)
 {
     $this->branch = null;
     if ($request->hasParameter('name') && $request->hasParameter('repository')) {
         $repository = RepositoryQuery::create()->filterByName($request->getParameter('repository'))->findOne();
         $this->forward404Unless($repository, "Repository not found");
         $this->branch = BranchQuery::create()->filterByName($request->getParameter('name'))->filterByRepository($repository)->findOne();
         // Dirty hack to make the breadcrumb work /!\
         if ($this->branch) {
             $this->redirect('default/fileList?branch=' . $this->branch->getId());
         }
     } elseif ($request->hasParameter('branch')) {
         $this->branch = BranchPeer::retrieveByPK($request->getParameter('branch'));
     }
     $this->forward404Unless($this->branch, "Branch not found");
     $this->getResponse()->setTitle($this->branch->getName());
     $this->repository = RepositoryPeer::retrieveByPK($this->branch->getRepositoryId());
     $this->forward404Unless($this->repository, "Repository not found");
     $files = FileQuery::create()->filterByBranchId($this->branch->getId())->find();
     $this->files = array();
     foreach ($files as $file) {
         $fileCommentsCount = CommentQuery::create()->filterByFileId($file->getId())->filterByType(CommentPeer::TYPE_FILE)->count();
         $fileCommentsCountNotChecked = CommentQuery::create()->filterByFileId($file->getId())->filterByType(CommentPeer::TYPE_FILE)->filterByCheckUserId(null)->count();
         $lineCommentsCount = CommentQuery::create()->filterByFileId($file->getId())->filterByCommit($file->getLastChangeCommit())->filterByType(CommentPeer::TYPE_LINE)->count();
         $lineCommentsCountNotChecked = CommentQuery::create()->filterByFileId($file->getId())->filterByCommit($file->getLastChangeCommit())->filterByType(CommentPeer::TYPE_LINE)->filterByCheckUserId(null)->count();
         $lastCommentId = 0;
         if ($fileCommentsCount || $lineCommentsCount) {
             $lastComment = CommentQuery::create()->filterByFileId($file->getId())->filterByCommit($file->getLastChangeCommit())->_or()->filterByType(CommentPeer::TYPE_FILE)->orderById(Criteria::DESC)->findOne();
             if ($lastComment) {
                 $lastCommentId = $lastComment->getId();
             }
         }
         $this->files[] = array_merge($file->toArray(), array('NbFileComments' => $fileCommentsCount + $lineCommentsCount, 'NbFileCommentsNotChecked' => $fileCommentsCountNotChecked + $lineCommentsCountNotChecked, 'LastCommentId' => $lastCommentId));
     }
     usort($this->files, array('self', 'sortPath'));
     $this->statusActions = StatusActionPeer::getStatusActionsForBoard(null, $this->repository->getId(), $this->branch->getId());
     $this->commentBoards = CommentPeer::getCommentsForBoard(null, $this->repository->getId(), $this->branch->getId());
 }
Пример #10
0
 /**
  * @param sfWebRequest $request
  * @return void
  */
 public function execute($request)
 {
     $this->file = FilePeer::retrieveByPK($request->getParameter('file'));
     $this->forward404Unless($this->file, "File not found");
     $this->getResponse()->setTitle(basename($this->file->getFilename()));
     $this->previousFileId = FileQuery::create()->select('Id')->filterByBranchId($this->file->getBranchId())->filterByFilename($this->file->getFilename(), Criteria::LESS_THAN)->filterByIsBinary(false)->orderByFilename(Criteria::DESC)->findOne();
     $this->nextFileId = FileQuery::create()->select('Id')->filterByBranchId($this->file->getBranchId())->filterByFilename($this->file->getFilename(), Criteria::GREATER_THAN)->filterByIsBinary(false)->orderByFilename(Criteria::ASC)->findOne();
     $this->branch = BranchPeer::retrieveByPK($this->file->getBranchId());
     $this->forward404Unless($this->branch, "Branch not found");
     $this->repository = RepositoryPeer::retrieveByPK($this->branch->getRepositoryId());
     $this->forward404Unless($this->repository, "Repository not found");
     $options = array();
     if ($request->getParameter('s', false)) {
         $options['ignore-all-space'] = true;
     }
     $this->fileContentLines = $this->gitCommand->getShowFileFromBranch($this->repository->getGitDir(), $this->branch->getCommitReference(), $this->file->getLastChangeCommit(), $this->file->getFilename(), $options);
     $fileLineCommentsModel = CommentQuery::create()->filterByFileId($this->file->getId())->filterByCommit($this->file->getLastChangeCommit())->filterByType(CommentPeer::TYPE_LINE)->find();
     $this->userId = $this->getUser()->getId();
     $this->fileLineComments = array();
     foreach ($fileLineCommentsModel as $fileLineCommentModel) {
         $this->fileLineComments[$fileLineCommentModel->getPosition()][] = $fileLineCommentModel;
     }
 }
Пример #11
0
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(BranchPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(BranchPeer::DATABASE_NAME);
         $criteria->add(BranchPeer::ID, $pks, Criteria::IN);
         $objs = BranchPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Пример #12
0
 public function executeBulkupload()
 {
     if ($this->getRequest()->getFileName('csvfile')) {
         $fileName = md5($this->getRequest()->getFileName('csvfile') . time() . rand(0, 99999));
         $ext = $this->getRequest()->getFileExtension('csvfile');
         $this->getRequest()->moveFile('csvfile', sfConfig::get('sf_upload_dir') . "//csvfiles//" . $fileName . ".csv");
         $fullname = $fileName . ".csv";
         //$fullpath = '/uploads/csvfiles/'.$fullname;
         $fp = sfConfig::get('sf_upload_dir') . "//csvfiles//" . $fileName . ".csv";
         $reader = new sfCsvReader($fp, ',', '"');
         $reader->open();
         $i = 1;
         $exist;
         $ignore;
         $log;
         $ignoreflag = 0;
         $success = 0;
         while ($data = $reader->read()) {
             $name[] = array();
             $name = explode(' ', $data[0]);
             $roll = $data[1];
             $enrol = $data[2];
             $branch = $data[3];
             $degree = $data[4];
             $year = $data[5];
             $c = new Criteria();
             $c->add(UserPeer::ENROLMENT, $enrol);
             $user = UserPeer::doSelectOne($c);
             if (!$user) {
                 $c = new Criteria();
                 $c->add(BranchPeer::CODE, $branch);
                 $br = BranchPeer::doSelectOne($c);
                 if (!$br) {
                     $br = new Branch();
                     $br->setName($branch);
                     $br->setCode($branch);
                     $br->save();
                 }
                 $c = new Criteria();
                 $c->add(DegreePeer::NAME, $degree);
                 $dg = DegreePeer::doSelectOne($c);
                 if (!$dg) {
                     $dg = new Degree();
                     $dg->setName($degree);
                     $dg->save();
                 }
                 $user = new User();
                 if ($roll) {
                     $user->setRoll($roll);
                     $user->setRollflag(sfConfig::get('app_defaultprivacy_roll'));
                 }
                 if ($enrol) {
                     $user->setEnrolment($enrol);
                     $user->setEnrolflag(sfConfig::get('app_defaultprivacy_enrol'));
                 } else {
                     $ignoreflag = 1;
                 }
                 if ($year) {
                     $user->setGraduationyear($year);
                     $user->setGraduationyearflag(sfConfig::get('app_defaultprivacy_year'));
                 }
                 $user->setBranchId($br->getId());
                 $user->setBranchflag(sfConfig::get('app_defaultprivacy_branch'));
                 $user->setDegreeId($dg->getId());
                 $user->setDegreeflag(sfConfig::get('app_defaultprivacy_degree'));
                 $user->setIslocked(sfConfig::get('app_islocked_unclaimed'));
                 $user->setUsertype(sfConfig::get('app_usertypecode_Alumni'));
                 $lastname = '';
                 $personal = new Personal();
                 $name[0] = str_replace('.', '', $name[0]);
                 $personal->setFirstname($name[0]);
                 if ($name[3]) {
                     $name[1] = str_replace('.', '', $name[1]);
                     $name[2] = str_replace('.', '', $name[2]);
                     $name[3] = str_replace('.', '', $name[3]);
                     $midname = $name[1] . " " . $name[2];
                     $personal->setMiddlename($midname);
                     $personal->setLastname($name[3]);
                     $lastname = $name[3];
                 } elseif ($name[2]) {
                     $name[1] = str_replace('.', '', $name[1]);
                     $name[2] = str_replace('.', '', $name[2]);
                     $personal->setMiddlename($name[1]);
                     $personal->setLastname($name[2]);
                     $lastname = $name[2];
                 } elseif ($name[1]) {
                     $name[1] = str_replace('.', '', $name[1]);
                     $personal->setLastname($name[1]);
                     $lastname = $name[1];
                 }
                 $uname_suffix = $branch . substr($year, -2);
                 if ($lastname) {
                     $username = $name[0] . '.' . $lastname . '@';
                 } else {
                     $username = $name[0] . '@';
                 }
                 $temp = 1;
                 $tempusername = $username;
                 while ($this->uniqueuser($tempusername . $uname_suffix)) {
                     $tempusername = $username . $temp;
                     $temp++;
                 }
                 $tempusername = $tempusername . $uname_suffix;
                 $user->setUsername($tempusername);
                 if ($ignoreflag == 0) {
                     $e = $user->save();
                     $personal->setUserId($user->getId());
                     $personal->save();
                     $success++;
                     $log[$i][0] = $e == 1 ? "{$i}) Uploaded Successfully" : $e;
                     $log[$i][1] = $data[0];
                 } else {
                     $ignore[] = $i;
                     $ignoreflag = 0;
                     $log[$i][0] = "{$i}) NO enrolment number";
                     $log[$i][1] = $data[0];
                 }
             } else {
                 $exist[] = $i;
                 $log[$i][0] = "{$i}) In Database as " . $user->getFullname() . ", " . $user->getBranchname() . " " . $user->getGraduationyear();
                 $log[$i][1] = $data[0];
             }
             $i++;
         }
         // while ($data = $reader->read()) ends here
         $reader->close();
         $this->log = $log;
         $this->success = $success;
         $this->ignored = $ignore;
         $this->exists = $exist;
     }
 }
Пример #13
0
 /**
  * Selects a collection of File objects pre-filled with all related objects except sfGuardUser.
  *
  * @param      Criteria  $criteria
  * @param      PropelPDO $con
  * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  * @return     array Array of File objects.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAllExceptsfGuardUser(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $criteria = clone $criteria;
     // Set the correct dbName if it has not been overridden
     // $criteria->getDbName() will return the same object if not set to another value
     // so == check is okay and faster
     if ($criteria->getDbName() == Propel::getDefaultDB()) {
         $criteria->setDbName(self::DATABASE_NAME);
     }
     FilePeer::addSelectColumns($criteria);
     $startcol2 = FilePeer::NUM_HYDRATE_COLUMNS;
     BranchPeer::addSelectColumns($criteria);
     $startcol3 = $startcol2 + BranchPeer::NUM_HYDRATE_COLUMNS;
     $criteria->addJoin(FilePeer::BRANCH_ID, BranchPeer::ID, $join_behavior);
     // symfony_behaviors behavior
     foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook) {
         call_user_func($sf_hook, 'BaseFilePeer', $criteria, $con);
     }
     $stmt = BasePeer::doSelect($criteria, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = FilePeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = FilePeer::getInstanceFromPool($key1))) {
             // We no longer rehydrate the object, since this can cause data loss.
             // See http://www.propelorm.org/ticket/509
             // $obj1->hydrate($row, 0, true); // rehydrate
         } else {
             $cls = FilePeer::getOMClass(false);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             FilePeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined Branch rows
         $key2 = BranchPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = BranchPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $cls = BranchPeer::getOMClass(false);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 BranchPeer::addInstanceToPool($obj2, $key2);
             }
             // if $obj2 already loaded
             // Add the $obj1 (File) to the collection in $obj2 (Branch)
             $obj2->addFile($obj1);
         }
         // if joined row is not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
Пример #14
0
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = BranchPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setName($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setCode($arr[$keys[2]]);
     }
 }
Пример #15
0
 /**
  * Save client profile content
  * @param web request $request
  */
 public function executeUpdate($request)
 {
     /**login user infomation**/
     $sf_user = $this->getUser();
     $sf_guard_user = $sf_user->getGuardUser();
     $sf_user_profile = $sf_guard_user->getProfile();
     $sf_user_id = $sf_guard_user->getId();
     $branch_id = $sf_user->getUserBranch()->getId();
     $company_id = $sf_user->getUserCompany()->getId();
     $this->marketing_options = '';
     $this->cop_record_updated = '';
     $client_user_id = NULL;
     //    if($sf_ser->isBranchOwner($sf_user_id) && $sf_user->hasAttribute('branch_id'))
     if ($sf_user->isBranchOwner($sf_user_id)) {
         //        $client_user_id = $this->getRequestParameter('id');
         $client_profile_id = $this->getRequestParameter('id');
         if (!empty($client_profile_id)) {
             $client_user = ProfilePeer::retrieveByPK($client_profile_id);
             $client_user_id = $client_user->getUserId();
         }
         /*
          * available in case branch owner is handling more than branch
          * if the client is new that it need branch_id from url
          */
         if ($this->getRequestParameter('branch_id')) {
             $branch_id = $this->getRequestParameter('branch_id');
         } elseif ($client_user_id) {
             $client_branch = new Criteria();
             $client_branch->add(BranchUsersPeer::USER_ID, $client_user_id);
             $client_branch->setDistinct();
             $branchId = BranchUsersPeer::doSelect($client_branch);
             $branch_id = $branchId[0]->getBranchId();
         }
         $company_id = BranchPeer::getCompanyId($branch_id);
     }
     $parent = $request->getParameter('opportunity_parent_exist', 0);
     $this->logindetails = array();
     $this->logindetails['username'] = '';
     $this->logindetails['password'] = '';
     $this->logindetails['confirm_password'] = '';
     $this->logindetails['budget'] = '';
     $this->logindetails['expected_close_date'] = '';
     $this->getSignedContractDate = '';
     $this->another_contact_list = '';
     $this->another_contact_form = new anotherContactPersonForm();
     $this->client_leads = ClientLeadPeer::getClientLeadsList($branch_id);
     $login_details = $request->getParameter('logindetail');
     $branch_service = new BranchService($branch_id, $sf_user_id);
     $this->marketing_options = $branch_service->getMarketingOptionList();
     $this->is_showlead = $branch_service->isShowLead();
     $this->sub_opportunity_exist = null;
     if ($login_details) {
         $this->logindetails = $login_details;
         if ($this->logindetails['expected_close_date']) {
             $this->logindetails['expected_close_date'] = date('Y-m-d', strtotime($this->logindetails['expected_close_date'])) . ' ' . date('H:i:s');
         }
     }
     $this->getSignedContractDate = $this->logindetails['signed_contract_date'];
     /*
      * get current branch branch office staff list (any one of these should be the sales person)
      */
     $tempsale = array();
     $tempsale[$sf_user_id] = $sf_user->getProfile()->getFullname();
     $sales = ProfilePeer::getBranchUsers($branch_id, sfGuardGroupPeer::BRANCH_OFFICE_STAFF);
     foreach ($sales as $salesid) {
         $tempsale[$salesid->getUserId()] = $salesid->getFullname();
     }
     $this->sales_persons = $tempsale;
     $this->default_sales = $sf_user_id;
     $client_profile = '';
     $this->client_profile = '';
     $client_id = $request->getParameter('id');
     if ($client_id) {
         $client_profile = ProfilePeer::retrieveByPK($client_id);
         $client_user_id = $client_profile->getUserId();
         $this->client_ranks = clientRankPeer::getClientOpportunityList($branch_id);
         $this->default_rank = 0;
         $this->default_sub_rank = null;
         $this->default_lead = 0;
         if (!empty($client_profile)) {
             $this->default_rank = $client_profile->getRank() ? $client_profile->getRank() : 0;
             $this->default_sub_rank = $client_profile->getSubOpportunity() ? $client_profile->getSubOpportunity() : null;
         }
         $this->client_profile = $client_profile;
         if ($client_profile->getOther2() == '') {
             $ref = $this->genRandomString();
             $client_profile->setOther2($ref);
         }
         $this->form = new ClientQuickForm($client_profile);
         $client_login = sfGuardUserPeer::retrieveByPK($client_user_id);
         $this->client_login = $client_login;
         $c = new Criteria();
         $c->add(anotherContactPersonPeer::USER_ID, $client_user_id, Criteria::EQUAL);
         $this->another_contact_list = anotherContactPersonPeer::doSelect($c);
     } else {
         $ref = $this->genRandomString();
         $this->form = new ClientQuickForm();
         $this->form->setDefault('other2', $ref);
         $this->client_ranks = clientRankPeer::getClientOpportunityList($branch_id);
         $this->default_rank = 0;
         $this->default_sub_rank = null;
         $this->default_lead = 0;
         if (!empty($client_profile)) {
             $this->default_rank = $client_profile->getSubOpportunity() ? $client_profile->getSubOpportunity() : $client_profile->getRank();
             $this->default_lead = $client_profile->getLead();
         }
     }
     /*
      * save data to database
      */
     if ($request->isMethod('post')) {
         $form_data = $request->getParameter('profile');
         $prefered = null;
         if ($request->getParameter('preferedPhone')) {
             $prefered = $request->getParameter('preferedPhone');
         } elseif ($request->getParameter('preferedAfterHourPhone')) {
             $prefered = $request->getParameter('preferedAfterHourPhone');
         } elseif ($request->getParameter('preferedMobile')) {
             $prefered = $request->getParameter('preferedMobile');
         }
         $form_data['updated_at'] = date('Y-m-d H:i:s');
         $form_data['updated_by_id'] = $sf_user_id;
         $form_data['prefered_contact'] = $prefered;
         $form_data['user_id'] = $client_user_id;
         $sales_id = $form_data['sales_id'];
         if (!$sales_id) {
             $form_data['sales_id'] = $sf_user_id;
         } else {
             $form_data['sales_id'] = $sales_id;
         }
         if ($parent) {
             $sub_opportunity = $form_data['rank'];
             $sub_opportunities = SubOpportunityPeer::retrieveByPK($sub_opportunity);
             $opportunities = clientRankPeer::retrieveByPK($sub_opportunities->getOpportunityId());
             $form_data['rank'] = $opportunities->getRankId();
             $form_data['sub_opportunity'] = $sub_opportunity;
             if ($opportunities->getRankId() == 7) {
                 $form_data['lead'] = ClientLeadPeer::getBranchLostId($branch_id);
             }
         } else {
             $form_data['sub_opportunity'] = null;
         }
         $client_rank = $form_data['rank'] - 1;
         $this->project = null;
         if ($client_rank == 5) {
             $c = new Criteria();
             $c->add(pmProjectsPeer::CLIENT_ID, $client_user_id);
             $c->addDescendingOrderByColumn(pmProjectsPeer::CREATED_AT);
             $this->project = pmProjectsPeer::doSelectOne($c);
         }
         $this->form->bind($form_data);
         if ($this->form->isValid()) {
             $status = sfConfig::get('mod_client_opportunity_accountstatus');
             $form_data['account_status'] = accountStatusPeer::getStatusId($status[$client_rank]) + 1;
             if ($this->form->isNew()) {
                 $form_data['created_by_id'] = $sf_user_id;
                 $form_data['created_at'] = date('Y-m-d H:i:s');
                 $form_data['updated_at'] = date('Y-m-d H:i:s');
                 $form_data['updated_by_id'] = $sf_user_id;
                 /*
                  *  save client instance into sfguard
                  */
                 $sf_object = new sfGuardUser();
                 $tools_obj = new myTools();
                 /*
                  * login infomation
                  */
                 if (!array_key_exists('username', $login_details) || !$login_details['username']) {
                     $client_username = $tools_obj->RandomUsernameGenerator();
                     $sf_object->setUsername($client_username);
                 } else {
                     $sf_object->setUsername($login_details['username']);
                 }
                 if (!array_key_exists('password', $login_details) || !$login_details['password']) {
                     $sf_object->setPassword($tools_obj->randomPasswordGenerator());
                 } else {
                     $sf_object->setPassword($login_details['username']);
                 }
                 $sf_object->save();
                 $sf_object->addGroupByName('client');
                 $new_user_id = $sf_object->getId();
                 $form_data['user_id'] = $new_user_id;
                 $enquiry_details = new Inquiry();
                 $enquiry_details->setUserId($new_user_id);
                 if ($login_details['budget'] != '') {
                     $enquiry_details->setBudget($login_details['budget']);
                 }
                 if ($login_details['expected_close_date'] != '') {
                     $enquiry_details->setExpectedCloseDate(date('Y-m-d', strtotime($login_details['expected_close_date'])));
                 } elseif ($login_details['expected_close_date'] == '') {
                     $enquiry_details->setExpectedCloseDate(date('Y-m-d', strtotime(date('Y-m-01') . ' +6 month')));
                 }
                 $enquiry_details->save();
                 /*
                  *  save instance into branch users
                  */
                 $branch_object = new BranchUsers();
                 $branch_object->addBranchUser($new_user_id, $branch_id);
                 // set intance into company users
                 $company_object = new CompanyUsers();
                 $company_object->addCompanyUser($new_user_id, $company_id);
             } else {
                 $enquiry_id = InquiryPeer::getEnquiryId($client_user_id);
                 $enquiry_details = InquiryPeer::retrieveByPK($enquiry_id);
                 if ($enquiry_details) {
                     $enquiry_details->setBudget($login_details['budget']);
                     $enquiry_details->setExpectedCloseDate(date('Y-m-d', strtotime($login_details['expected_close_date'])));
                     $enquiry_details->save();
                 } else {
                     $enquiry_details = new Inquiry();
                     $enquiry_details->setUserId($client_login->getId());
                     if ($login_details['budget'] != '') {
                         $enquiry_details->setBudget($login_details['budget']);
                     }
                     if ($login_details['expected_close_date'] != '') {
                         $enquiry_details->setExpectedCloseDate(date('Y-m-d', strtotime($login_details['expected_close_date'])));
                     }
                     $enquiry_details->save();
                 }
                 if ($client_login) {
                     $client_login->setUsername($this->logindetails['username']);
                     if ($this->logindetails['password'] != '') {
                         $client_login->setPassword($this->logindetails['password']);
                     }
                     $client_login->save();
                     $new_user_id = $client_login->getId();
                 }
             }
             if ($login_details['signed_contract_value'] != '') {
                 $conn = Propel::getConnection();
                 //                    need update only one record in the furture
                 $cor = new Criteria();
                 $cor->add(pmProjectsPeer::CLIENT_ID, $client_user_id);
                 $cor->addDescendingOrderByColumn(pmProjectsPeer::CREATED_AT);
                 $cor_new = new Criteria();
                 $cor_new->add(pmProjectsPeer::ACTUAL_BUILD_COST, $login_details['signed_contract_value']);
                 $cor_new->add(pmProjectsPeer::UPDATED_BY_ID, $sf_user_id);
                 $cor_new->add(pmProjectsPeer::UPDATED_AT, date('Y-m-d H:i:s'));
                 BasePeer::doUpdate($cor, $cor_new, $conn);
             }
             /*
              * save the form to profile
              */
             $profile = $this->form->save();
             $profile->setUserId($new_user_id ? $new_user_id : $client_user_id);
             $profile->save();
             $old_opportunity_id = 0;
             $old_sub_opportunity_id = 0;
             $old_opportunity_id = $this->default_rank;
             $old_sub_opportunity_id = $this->default_sub_rank;
             $new_opp_record = false;
             $c_opp_record = new Criteria();
             $c_opp_record->add(ClientOpportunityRecordPeer::USER_ID, $client_user_id);
             if ($old_sub_opportunity_id) {
                 $c_opp_record->add(ClientOpportunityRecordPeer::SUB_OPPORTUNITY_ID, $old_sub_opportunity_id, Criteria::IN);
                 $opportunity_records = ClientOpportunityRecordPeer::doSelect($c_opp_record);
             } elseif ($old_opportunity_id) {
                 $c_opp_record->add(ClientOpportunityRecordPeer::OPPORTUNITY_ID, $old_opportunity_id, Criteria::IN);
                 $opportunity_records = ClientOpportunityRecordPeer::doSelect($c_opp_record);
             } else {
                 $opportunity_records = Null;
             }
             if (empty($opportunity_records)) {
                 $new_opp_record = true;
             }
             $new_opportunity_id = $profile->getRank();
             $new_sub_opportunity_id = $profile->getSubOpportunity();
             if ($new_opp_record) {
                 $client_opportunity_record = new ClientOpportunityRecord();
                 $client_opportunity_record->setOpportunityId($new_opportunity_id);
                 $client_opportunity_record->setSubOpportunityId($new_sub_opportunity_id);
                 $client_opportunity_record->setUserId($profile->getUserId());
                 $client_opportunity_record->setCreatedById($sf_user_id);
                 $client_opportunity_record->setUpdatedById($sf_user_id);
                 $client_opportunity_record->save();
             } else {
                 $conn = Propel::getConnection();
                 $client_opportunity_record_criteria = new Criteria();
                 $client_opportunity_record_criteria->add(ClientOpportunityRecordPeer::USER_ID, $profile->getUserId());
                 $client_opportunity_record_criteria->add(ClientOpportunityRecordPeer::OPPORTUNITY_ID, $new_opportunity_id);
                 $client_opportunity_record_criteria->add(ClientOpportunityRecordPeer::SUB_OPPORTUNITY_ID, $new_sub_opportunity_id);
                 $cor_new = new Criteria();
                 if ($new_opportunity_id == 6) {
                     if (!empty($this->getSignedContractDate)) {
                         $signed_updated_date = date('Y-m-d', strtotime($this->getSignedContractDate)) . ' ' . date('H:i:s');
                         $cor_new->add(ClientOpportunityRecordPeer::UPDATED_AT, $signed_updated_date);
                     }
                 } else {
                     $cor_new->add(ClientOpportunityRecordPeer::UPDATED_AT, date('Y-m-d H:i:s'));
                 }
                 $cor_new->add(ClientOpportunityRecordPeer::UPDATED_BY_ID, $sf_user_id);
                 BasePeer::doUpdate($client_opportunity_record_criteria, $cor_new, $conn);
             }
             if ($old_opportunity_id != $new_opportunity_id || $old_sub_opportunity_id != $new_sub_opportunity_id) {
                 $client_opportunity_log = new ClientOpportunityLog();
                 $client_opportunity_log->setUserId($profile->getUserId());
                 $client_opportunity_log->setOpportunityId($new_opportunity_id);
                 $client_opportunity_log->setSubOpportunityId($new_sub_opportunity_id);
                 $client_opportunity_log->setCreatedById($sf_user_id);
                 $client_opportunity_log->save();
             }
             /*
              *  delete record from another contact from current client
              */
             $c = new Criteria();
             $c->add(anotherContactPersonPeer::USER_ID, $profile->getUserId());
             $another = anotherContactPersonPeer::doDelete($c);
             // add record from client
             $another_details = $request->getParameter('contact_person');
             $no_of_fields = 5;
             $count_person_list = count($another_details) / $no_of_fields;
             $j = $no_of_fields;
             for ($i = 0; $i < $count_person_list - 1; $i++) {
                 $fname = $another_details[$j]['fname'];
                 $lname = $another_details[$j + 1]['lname'];
                 if ($fname != '' || $lname != '') {
                     $an_details = new anotherContactPerson();
                     $an_details->setUserId($profile->getUserId());
                     $an_details->setFname($another_details[$j++]['fname']);
                     $an_details->setLname($another_details[$j++]['lname']);
                     $an_details->setPhone($another_details[$j++]['phone']);
                     $an_details->setEmail($another_details[$j++]['email']);
                     $an_details->setMobile($another_details[$j++]['mobile']);
                     $an_details->save();
                 } else {
                     $j = $j + $no_of_fields;
                 }
             }
             if (!$request->getParameter('rdindex')) {
                 $profile_id = $profile->getId();
                 $profile_user_id = $profile->getUserId();
                 // save client details in the activity logs table
                 $modification_message = $this->form->isNew() ? 'Create Profile' : 'Update Profile';
                 $this->saveHistory($modification_message, $profile_user_id);
                 if ($this->form->isNew()) {
                     $reminder = sfConfig::get('mod_client_messages_msg4');
                     $sf_user->setFlash('notice', $reminder);
                     $this->redirect('client/show?id=' . $profile_id);
                 }
                 $client_info = sfConfig::get('mod_client_messages_msg2');
                 $sf_user->setFlash('notice', $client_info);
                 $this->redirect('client/show?id=' . $profile_id);
             }
             $profile_id = $profile->getId();
             $this->redirect('inquiry/edit?id=' . $profile_id);
         }
         if (isset($profile)) {
             $this->sub_opportunity_exist = $profile->getSubOpportunity() ? 1 : 0;
         }
         $this->setTemplate('edit');
     }
 }
Пример #16
0
 public static function doSelectJoinAllExceptDegree(Criteria $c, $con = null)
 {
     $c = clone $c;
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     UserPeer::addSelectColumns($c);
     $startcol2 = UserPeer::NUM_COLUMNS - UserPeer::NUM_LAZY_LOAD_COLUMNS + 1;
     BranchPeer::addSelectColumns($c);
     $startcol3 = $startcol2 + BranchPeer::NUM_COLUMNS;
     $c->addJoin(UserPeer::BRANCH_ID, BranchPeer::ID);
     $rs = BasePeer::doSelect($c, $con);
     $results = array();
     while ($rs->next()) {
         $omClass = UserPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj1 = new $cls();
         $obj1->hydrate($rs);
         $omClass = BranchPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj2 = new $cls();
         $obj2->hydrate($rs, $startcol2);
         $newObject = true;
         for ($j = 0, $resCount = count($results); $j < $resCount; $j++) {
             $temp_obj1 = $results[$j];
             $temp_obj2 = $temp_obj1->getBranch();
             if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
                 $newObject = false;
                 $temp_obj2->addUser($obj1);
                 break;
             }
         }
         if ($newObject) {
             $obj2->initUsers();
             $obj2->addUser($obj1);
         }
         $results[] = $obj1;
     }
     return $results;
 }
Пример #17
0
 /**
  * @param int $statusId
  *
  * @return string
  */
 protected function getLabelStatus($statusId)
 {
     return BranchPeer::getBasecampLabelStatus($statusId);
 }
Пример #18
0
    public function executeRegistration()
    {
        $userid = $this->getRequestParameter('userid');
        $this->getUser()->getAttributeHolder()->remove('claimerid');
        $roll = $this->getRequestParameter('roll');
        $hawa = $this->getRequestParameter('hawa');
        $city = $this->getRequestParameter('city');
        $hod = $this->getRequestParameter('hod');
        $director = $this->getRequestParameter('director');
        $teacher = $this->getRequestParameter('favteacher');
        $lanka = $this->getRequestParameter('favlankashop');
        $email = $this->getRequestParameter('email');
        $other = $this->getRequestParameter('otherinfo');
        $dusername = $this->getRequestParameter('dusername');
        $mob = $this->getRequestParameter('mob');
        if (!$userid) {
            $fname = $this->getRequestParameter('fname');
            $mname = $this->getRequestParameter('mname');
            $lname = $this->getRequestParameter('lname');
            $year = $this->getRequestParameter('year');
            $dusername = $this->getRequestParameter('dusername');
            $formerrors1 = array();
            if (!$fname) {
                $formerrors1[] = 'Please enter first name';
            }
            if (!$lname) {
                $formerrors1[] = 'Please enter last name';
            }
            if (!$dusername) {
                $formerrors1[] = 'Please enter username';
            }
            if ($formerrors1) {
                $this->getRequest()->setErrors($formerrors1);
                $this->forward('home', 'getmyaccount');
            }
            $branchn = BranchPeer::retrieveByPK($this->getRequestParameter('branchid'));
            $degreen = DegreePeer::retrieveByPK($this->getRequestParameter('degreeid'));
            if (!$dusername) {
                $newusername = $fname . "." . $lname . "@" . $branchn->getCode() . substr($year, -2);
            } else {
                $newusername = $dusername;
            }
            $currentyear = date('Y');
            if ($currentyear <= $year) {
                $usertype = '0';
            } else {
                $usertype = '1';
            }
            $user = new User();
            $user->setUsername($newusername);
            $user->setRoll($roll);
            $user->setRollflag(sfConfig::get('app_defaultprivacy_roll'));
            $user->setGraduationyear($year);
            $user->setGraduationyearflag(sfConfig::get('app_defaultprivacy_year'));
            $user->setBranchId($branchn->getId());
            $user->setBranchflag(sfConfig::get('app_defaultprivacy_branch'));
            $user->setDegreeId($degreen->getId());
            $user->setDegreeflag(sfConfig::get('app_defaultprivacy_degree'));
            $user->setUsertype($usertype);
            $user->setTempemail($email);
            $user->setIslocked(sfConfig::get('app_islocked_newreg'));
            $user->save();
            $personal = new Personal();
            $personal->setUserId($user->getId());
            $personal->setFirstname($fname);
            $personal->setMiddlename($mname);
            $personal->setLastname($lname);
            $personal->setEmail($email);
            $personal->setMobile($mob);
            $personal->save();
            $userid = $user->getId();
        } else {
            $user = UserPeer::retrieveByPK($userid);
            $user->setIslocked(sfConfig::get('app_islocked_claimed'));
            $user->save();
        }
        $c = new Criteria();
        $c->add(ClaiminfoPeer::USER_ID, $userid);
        $claiminfo = ClaiminfoPeer::doSelectOne($c);
        if ($claiminfo) {
            $this->user = $claiminfo->getUser();
            $this->claiminfo = $claiminfo;
        } else {
            $claiminfo = new Claiminfo();
            $claiminfo->setUserId($userid);
            $claiminfo->setRoll($roll);
            $claiminfo->setHawa($hawa);
            $claiminfo->setCity($city);
            $claiminfo->setHod($hod);
            $claiminfo->setDirector($director);
            $claiminfo->setTeacher($teacher);
            $claiminfo->setLankashop($lanka);
            $claiminfo->setOther($other);
            $claiminfo->setDusername($dusername);
            $claiminfo->save();
            $this->claiminfo = $claiminfo;
            $this->user = $user;
            if ($user) {
                $username = $user->getUsername();
                $personal = $user->getPersonal();
                $personal->setEmail($email);
                $personal->save();
                $sendermail = sfConfig::get('app_from_mail');
                $sendername = sfConfig::get('app_from_name');
                $to = sfConfig::get('app_to_adminmail');
                $subject = "Registration request for ITBHU Global Org";
                $body = '
	  Hi,
	 
	  I want to connect to ITBHU Global. My verification information is: 
	
	';
                $body = $body . 'Roll Number           : ' . $roll . '
	';
                $body = $body . 'HAWA                  :  ' . $hawa . '
	';
                $body = $body . 'City                  :  ' . $city . '
	';
                $body = $body . 'HoD                   :  ' . $hod . '
	';
                $body = $body . 'Director              :  ' . $director . '
	';
                $body = $body . 'Favourite Teacher     :  ' . $teacher . '
	';
                $body = $body . 'Favuorite Lanka Shop  :  ' . $lanka . '
	';
                $body = $body . 'My Email              :  ' . $email . '
	';
                $body = $body . 'Username I am claiming: ' . $username . '
	';
                $body = $body . 'Desired Username      : '******'
	';
                $body = $body . 'Thanks,';
                $body = $body . '
	' . $user->getFullname();
                //send mail to admin
                $mail = myUtility::sendmail($sendermail, $sendername, $sendermail, $sendername, $sendermail, $to, $subject, $body);
                //send mail to class authorizer
                $ca = new Criteria();
                $ca->add(UserPeer::GRADUATIONYEAR, $user->getGraduationyear());
                $ca->add(UserPeer::BRANCH_ID, $user->getBranchId());
                $ca->addJoin(UserPeer::ID, UserrolePeer::USER_ID);
                $ca->add(UserrolePeer::ROLE_ID, sfConfig::get('app_role_auth'));
                $authusers = UserPeer::doSelect($ca);
                //if class authorizers are available.
                if ($authusers) {
                    foreach ($authusers as $authuser) {
                        $toauth = $authuser->getEmail();
                        $mail = myUtility::sendmail($sendermail, $sendername, $sendermail, $sendername, $sendermail, $toauth, $subject, $body);
                    }
                    $user->setAuthcode(sfConfig::get('app_authcode_classauth'));
                    $user->save();
                } else {
                    //get other authorizers
                    $ugyear = $user->getGraduationyear() - 2;
                    $lgyear = $user->getGraduationyear() + 2;
                    $oa = new Criteria();
                    $oa->add(UserPeer::GRADUATIONYEAR, $ugyear, Criteria::GREATER_EQUAL);
                    $oa->add(UserPeer::GRADUATIONYEAR, $lgyear, Criteria::LESS_EQUAL);
                    $oa->add(UserPeer::BRANCH_ID, $user->getBranchId());
                    $oa->addJoin(UserPeer::ID, UserrolePeer::USER_ID);
                    $oa->add(UserrolePeer::ROLE_ID, sfConfig::get('app_role_auth'));
                    $authuserspm = UserPeer::doSelect($oa);
                    //if other authorizers are available
                    if ($authuserspm) {
                        foreach ($authuserspm as $authuserpm) {
                            $toauth = $authuserpm->getEmail();
                            $mail = myUtility::sendmail($sendermail, $sendername, $sendermail, $sendername, $sendermail, $toauth, $subject, $body);
                            $user->setAuthcode(sfConfig::get('app_authcode_otherauth'));
                            $user->save();
                        }
                    } else {
                        // no authorizers were available, send to master list of authorizers
                        $ma = new Criteria();
                        $ma->addJoin(UserPeer::ID, UserrolePeer::USER_ID);
                        $ma->add(UserrolePeer::ROLE_ID, sfConfig::get('app_role_masterauth'));
                        $mauths = UserPeer::doSelect($ma);
                        if ($mauths) {
                            foreach ($mauths as $mauth) {
                                $toauth = $mauth->getEmail();
                                $mail = myUtility::sendmail($sendermail, $sendername, $sendermail, $sendername, $sendermail, $toauth, $subject, $body);
                                $user->setAuthcode(sfConfig::get('app_authcode_masterauth'));
                                $user->save();
                            }
                        } else {
                            $user->setAuthcode(sfConfig::get('app_authcode_none'));
                            $user->save();
                        }
                    }
                }
                $sendermail = sfConfig::get('app_from_mail');
                $sendername = sfConfig::get('app_from_name');
                $to = $email;
                $subject = "Registration request for ITBHU Global Org";
                $body = '
				Dear ' . $user->getFullname() . ',
				
				Thank you for your connect request. We\'ll get back to you shortly.	
				
				
				Admin,
				ITBHU Global
				';
                $mail = myUtility::sendmail($sendermail, $sendername, $sendermail, $sendername, $sendermail, $to, $subject, $body);
            }
        }
        // saving the checkbox data in db
        $c = new Criteria();
        $c->add(PersonalPeer::USER_ID, $user->getId());
        $this->personal = PersonalPeer::doSelectOne($c);
        $c = new Criteria();
        $worktypes = WorktypePeer::doSelect($c);
        foreach ($worktypes as $worktype) {
            if ($this->getRequestParameter($worktype->getId())) {
                $personalWorktype = new PersonalWorktype();
                $personalWorktype->setPersonalId($this->personal->getId());
                $personalWorktype->setWorktypeId($worktype->getId());
                $personalWorktype->save();
            }
        }
    }
Пример #19
0
 /**
  * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
  * feature (like MySQL or SQLite).
  *
  * This method is not very speedy because it must perform a query first to get
  * the implicated records and then perform the deletes by calling those Peer classes.
  *
  * This method should be used within a transaction if possible.
  *
  * @param      Criteria $criteria
  * @param      PropelPDO $con
  * @return     int The number of affected rows (if supported by underlying database driver).
  */
 protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
 {
     // initialize var to track total num of affected rows
     $affectedRows = 0;
     // first find the objects that are implicated by the $criteria
     $objects = RepositoryPeer::doSelect($criteria, $con);
     foreach ($objects as $obj) {
         // delete related Branch objects
         $criteria = new Criteria(BranchPeer::DATABASE_NAME);
         $criteria->add(BranchPeer::REPOSITORY_ID, $obj->getId());
         $affectedRows += BranchPeer::doDelete($criteria, $con);
         // delete related StatusAction objects
         $criteria = new Criteria(StatusActionPeer::DATABASE_NAME);
         $criteria->add(StatusActionPeer::REPOSITORY_ID, $obj->getId());
         $affectedRows += StatusActionPeer::doDelete($criteria, $con);
     }
     return $affectedRows;
 }
Пример #20
0
    if ($fname) {
        echo "<b>" . $fname . "</b>";
    } else {
        echo '<i>any</i>';
    }
    ?>
				<br>Last Name: <?php 
    if ($lname) {
        echo "<b>" . $lname . "</b>";
    } else {
        echo '<i>any</i>';
    }
    ?>
				<br>Branch: <?php 
    if ($br) {
        echo "<b>" . BranchPeer::retrieveByPK($br)->getName() . "</b>";
    } else {
        echo '<i>any</i>';
    }
    ?>
				<br>Year: <?php 
    if ($yr) {
        echo "<b>" . $yr . "</b>";
    } else {
        echo '<i>any</i>';
    }
    ?>
				<br>Chapter: <?php 
    if ($chap) {
        echo "<b>" . ChapterPeer::retrieveByPK($chap)->getname() . "</b>";
    } else {
Пример #21
0
 /**
  * Find object by primary key using raw SQL to go fast.
  * Bypass doSelect() and the object formatter by using generated code.
  *
  * @param     mixed $key Primary key to use for the query
  * @param     PropelPDO $con A connection object
  *
  * @return    Branch A model object, or null if the key is not found
  */
 protected function findPkSimple($key, $con)
 {
     $sql = 'SELECT `ID`, `REPOSITORY_ID`, `NAME`, `BASE_BRANCH_NAME`, `COMMIT_REFERENCE`, `LAST_COMMIT`, `LAST_COMMIT_DESC`, `IS_BLACKLISTED`, `REVIEW_REQUEST`, `STATUS`, `COMMIT_STATUS_CHANGED`, `USER_STATUS_CHANGED`, `DATE_STATUS_CHANGED`, `CREATED_AT`, `UPDATED_AT` FROM `branch` WHERE `ID` = :p0';
     try {
         $stmt = $con->prepare($sql);
         $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
         $stmt->execute();
     } catch (Exception $e) {
         Propel::log($e->getMessage(), Propel::LOG_ERR);
         throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
     }
     $obj = null;
     if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $obj = new Branch();
         $obj->hydrate($row);
         BranchPeer::addInstanceToPool($obj, (string) $row[0]);
     }
     $stmt->closeCursor();
     return $obj;
 }
Пример #22
0
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  * The default key type is the column's phpname (e.g. 'AuthorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = BranchPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setRepositoryId($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setName($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setBaseBranchName($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setCommitReference($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setLastCommit($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setLastCommitDesc($arr[$keys[6]]);
     }
     if (array_key_exists($keys[7], $arr)) {
         $this->setIsBlacklisted($arr[$keys[7]]);
     }
     if (array_key_exists($keys[8], $arr)) {
         $this->setReviewRequest($arr[$keys[8]]);
     }
     if (array_key_exists($keys[9], $arr)) {
         $this->setStatus($arr[$keys[9]]);
     }
     if (array_key_exists($keys[10], $arr)) {
         $this->setCommitStatusChanged($arr[$keys[10]]);
     }
     if (array_key_exists($keys[11], $arr)) {
         $this->setUserStatusChanged($arr[$keys[11]]);
     }
     if (array_key_exists($keys[12], $arr)) {
         $this->setDateStatusChanged($arr[$keys[12]]);
     }
     if (array_key_exists($keys[13], $arr)) {
         $this->setCreatedAt($arr[$keys[13]]);
     }
     if (array_key_exists($keys[14], $arr)) {
         $this->setUpdatedAt($arr[$keys[14]]);
     }
 }
Пример #23
0
 public function getBranch($con = null)
 {
     include_once 'lib/model/om/BaseBranchPeer.php';
     if ($this->aBranch === null && $this->branch_id !== null) {
         $this->aBranch = BranchPeer::retrieveByPK($this->branch_id, $con);
     }
     return $this->aBranch;
 }