/** * @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) { $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); }
/** * @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()); }
/** * @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; } }
public function executeEditbranch() { $branchid = $this->getRequestParameter('id'); $c = new Criteria(); $c->add(BranchPeer::NAME, $this->getRequestParameter('branch')); $c->add(BranchPeer::ID, $branchid, Criteria::NOT_EQUAL); $exbranch = BranchPeer::doSelectOne($c); $c->clear(); $c->add(BranchPeer::CODE, $this->getRequestParameter('code')); $c->add(BranchPeer::ID, $branchid, Criteria::NOT_EQUAL); $excode = BranchPeer::doSelectOne($c); if ($exbranch) { $this->setFlash('notice', 'Brach could not be edited. A branch with same name already exists.'); } elseif ($excode) { $this->setFlash('notice', 'Branch could not be edited. A branch with same code already exists.'); } else { $branch = BranchPeer::retrieveByPK($branchid); $branch->setName($this->getRequestParameter('branch')); $branch->setCode($this->getRequestParameter('code')); $branch->save(); $this->setFlash('notice', 'Branch Edited successfully.'); } $this->redirect('/admin/branches'); }
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 {
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(); } } }
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; }