Inheritance: extends AppModel
Esempio n. 1
0
 /**
  * For listing the State
  * @author        Praveen Singh
  * @method        getState
  * @param         id
  * @return        one row of Module Role table 
  * @since         version 0.0.1
  * @version       0.2.9
  */
 function getState($statId)
 {
     App::import("Model", "State");
     $model = new State();
     $datas = $model->find("first", array('conditions' => array('State.id' => $statId)));
     return $datas;
 }
Esempio n. 2
0
 public function parseRequest()
 {
     // init the state library
     $state = new State();
     // get the request
     $request = $state->getInput('request');
     if (!empty($request)) {
         // explode request
         $request_array = explode('/', $request);
         if (!empty($request_array)) {
             // store the controller
             $this->controller = $request_array[0];
         }
         if (isset($request_array[1])) {
             // store the action
             $this->action = $request_array[1];
         }
         if (count($request_array) > 2) {
             // foreach extra key
             for ($i = 2; $i < count($request_array); $i++) {
                 // store as a param
                 $this->params[$i - 2] = $request_array[$i];
             }
         }
     }
 }
Esempio n. 3
0
 public function __construct($legislation_id = 0)
 {
     parent::__construct('legislation', $legislation_id);
     if ($legislation_id) {
         $state = new State($this->region_id());
         $logo = LOGO_PATH . strtolower('state_' . $state->state_abbr() . '_' . $this->current_chamber()) . '.png';
         $location = $state->state_name() . ' State ' . $this->current_chamber();
         list($category_id, $category_name) = Category::legislation_get_category($this->current_location());
         $committee = Category::get_location($this->current_location());
         $this->legislator_ids = $this->get_legislator_ids();
         $legislators = array();
         if (!empty($this->legislator_ids)) {
             foreach ($this->legislator_ids as $id) {
                 $legislators[] = new Legislator($id);
             }
         }
         $this->sponsors = Legislation::get_legislator_data($legislators, $committee);
         $this->bill = $this->_extract_bill_id();
         $this->image = $logo;
         $this->bill_location = $location;
         $this->location_description = $committee;
         $this->category = array('id' => $category_id, 'name' => $category_name);
         $this->status = new Status($this->status_id());
         $this->date_introduced_parts = get_date_parts($this->date_introduced());
         $this->date_heard_parts = get_date_parts($this->date_heard());
         $this->_get_public_opinion();
         $this->comment_data = $this->get_comment_data();
     }
 }
Esempio n. 4
0
 /**
  * Returns event identifier
  *
  * @return string
  */
 public function getIdentifier()
 {
     if (!$this->identifier) {
         $this->identifier = sha1(microtime(true) . implode('', $this->tags) . State::getTestSuiteName() . State::getTestClassName() . State::getTestMethodName() . $this->state->getPageUrl());
     }
     return $this->identifier;
 }
 function displayData()
 {
     $cityTemp = CityManager::getSingleCity('id', $this->church->getIdCity());
     if ($cityTemp === NULL) {
         $cityTemp = new City();
     }
     $stateTemp = CityManager::getSingleState('id', $cityTemp->getIdState());
     $cityString = "*************************";
     if ($stateTemp === NULL) {
         $stateTemp = new State();
     } else {
         $cityString = $cityTemp->getName() . ", " . $stateTemp->getShortName();
     }
     $this->SetFont('Arial', 'B', 10);
     $cellSizeY = 5;
     for ($i = 0; $i < 3; $i++) {
         //Get the data necesary of create the document
         $this->SetXY($x + 100, $i * 60 + $y + 40 - $cellSizeY);
         $this->Cell(80, $cellSizeY, iconv('utf-8', 'cp1252', $this->church->getName()), 0, 0, 'C');
         $this->SetXY($x + 100, $i * 60 + $y + 47 - $cellSizeY);
         $this->Cell(80, $cellSizeY, iconv('utf-8', 'cp1252', $this->church->getAddress()), 0, 0, 'C');
         $this->SetXY($x + 100, $i * 60 + $y + 54 - $cellSizeY);
         $this->Cell(80, $cellSizeY, iconv('utf-8', 'cp1252', 'CP. ' . $this->church->getPostalCode()), 0, 0, 'C');
         $this->SetXY($x + 100, $i * 60 + $y + 61 - $cellSizeY);
         $this->Cell(80, $cellSizeY, iconv('utf-8', 'cp1252', $cityString), 0, 0, 'C');
     }
 }
Esempio n. 6
0
 public function testPersist()
 {
     $model = new State($this->config, $this->writer);
     $constraint = new \PHPUnit_Framework_Constraint_IsInstanceOf('Magento\\Framework\\App\\Cache\\Type\\ConfigSegment');
     $this->writer->expects($this->once())->method('update')->with($constraint);
     $model->persist();
 }
Esempio n. 7
0
 /**
  * Handle exception
  *
  * @param \Exception $e
  * @return void
  */
 protected function handleException($e)
 {
     $needToMaskDisplayMessage = !$e instanceof \Magento\Framework\Exception\LocalizedException && $this->appState->getMode() != State::MODE_DEVELOPER;
     $displayMessage = $needToMaskDisplayMessage ? (string) new \Magento\Framework\Phrase('An error occurred while processing your request') : $e->getMessage();
     $this->messageManager->addError($displayMessage);
     $this->logger->critical($e->getMessage());
 }
Esempio n. 8
0
 public static function cloneState(State &$state)
 {
     $instance = new State($state->getStream());
     foreach ($state as $char) {
         $instance->appendChar($char);
     }
     return $instance;
 }
Esempio n. 9
0
 public function testGetMetadata()
 {
     $state = new State('stateName', ['param1' => 'value1', 'param2' => 'value2']);
     $this->assertEquals(['param1' => 'value1', 'param2' => 'value2'], $state->getMetadata());
     $this->assertEquals('value1', $state->getMetadata('param1'));
     $this->assertEquals('value2', $state->getMetadata('param2'));
     $this->assertEquals(null, $state->getMetadata('UNEXISTED_KEY'));
 }
Esempio n. 10
0
 /**
  * @test
  */
 public function stateShouldKeepItemsByRuleNumberAndPosition()
 {
     $item1 = new Item(new Rule(1, 'E', array('E', '+', 'T')), 0);
     $state = new State(0, array($item1));
     $this->assertSame($item1, $state->get(1, 0));
     $item2 = new Item(new Rule(2, 'T', array('T', '+', 'F')), 0);
     $state->add($item2);
     $this->assertSame($item2, $state->get(2, 0));
 }
Esempio n. 11
0
 function valuesFromForm(&$values, State $record)
 {
     if ($values['_is_disabled']) {
         $values['tag'] = $values['tag'] ? $values['tag'] * -1 : -1;
     }
     if (!$record->pk()) {
         $values['state'] = $this->country . '-' . $values['state'];
     }
 }
Esempio n. 12
0
 /**
  * Execute SampleData module installation.
  * Catch exception if it appeared and continue installation
  *
  * @param InstallerInterface $installer
  * @return void
  */
 public function exec(InstallerInterface $installer)
 {
     try {
         $this->appState->emulateAreaCode('setup', [$installer, 'install']);
         $this->state->setInstalled();
     } catch (\Exception $e) {
         $this->state->setError();
         $this->logger->error('Sample Data error: ' . $e->getMessage());
     }
 }
Esempio n. 13
0
 function getStateList($countryCode)
 {
     App::import("Model", "State");
     $model = new State();
     $con2 = $model->find('list', array('fields' => array('State.id', 'State.statename'), 'conditions' => array('State.countryid' => $countryCode)));
     if (empty($con2)) {
         return 0;
     } else {
         return $con2;
     }
 }
Esempio n. 14
0
 /**
  * Enqueues the script file.
  *
  * @wp-hook wp_footer
  *
  * @return void
  */
 public function enqueue()
 {
     if (!$this->state->is_active()) {
         return;
     }
     $url = plugin_dir_url($this->file);
     $infix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
     $file = 'assets/css/frontend' . $infix . '.css';
     $path = plugin_dir_path($this->file);
     $version = filemtime($path . $file);
     wp_enqueue_style('that-was-helpful', $url . $file, array(), $version);
 }
Esempio n. 15
0
 /**
  * Creates individual Entry objects of the appropriate type and
  * stores them as members of this entry based upon DOM data.
  *
  * @param DOMNode $child The DOMNode to process
  */
 protected function takeChildFromDOM($child)
 {
     $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
     switch ($absoluteNodeName) {
         case $this->lookupNamespace('yt') . ':' . 'state':
             $state = new State();
             $state->transferFromDOM($child);
             $this->_state = $state;
             break;
         default:
             parent::takeChildFromDOM($child);
             break;
     }
 }
Esempio n. 16
0
 /**
  * Enqueues the script file.
  *
  * @wp-hook wp_footer
  *
  * @return void
  */
 public function enqueue()
 {
     if (!$this->state->is_active()) {
         return;
     }
     $url = plugin_dir_url($this->file);
     $infix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
     $file = 'assets/js/frontend' . $infix . '.js';
     $path = plugin_dir_path($this->file);
     $version = filemtime($path . $file);
     wp_enqueue_script($this->handle, $url . $file, array('jquery'), $version, TRUE);
     $data = array('action' => $this->action, 'nonce' => $this->nonce, 'url' => admin_url('admin-ajax.php', 'relative'));
     wp_localize_script($this->handle, 'tfThatWasHelpfulData', $data);
 }
Esempio n. 17
0
 /**
  * Returns the state with the given id. If no such state exists, a new
  * state is returned.
  */
 function get($_id)
 {
     $_id = 'x';
     $state = new State();
     $state->id = $_id;
     if (!is_readable($this->_filename_of($_id))) {
         return $state;
     }
     $pairs = parse_ini_file($this->_filename_of($_id));
     foreach ($pairs as $key => $value) {
         $state->set($key, $value);
     }
     return $state;
 }
Esempio n. 18
0
 public function actionCreateOrg()
 {
     $org = Organization::model()->count();
     if ($org == 0) {
         $this->layout = 'installation_layout';
         $model = new Organization();
         $user = new User();
         $auth_assign = new AuthAssignment();
         // Uncomment the following line if AJAX validation is needed
         $this->performAjaxValidation($model);
         if (isset($_POST['Organization']['organization_name']) && !empty($_POST['Organization']['phone']) && !empty($_POST['Organization']['email'])) {
             $country_model = new Country();
             $country_model->name = $_POST['Organization']['country'];
             $country_model->save();
             $state_model = new State();
             $state_model->state_name = $_POST['Organization']['state'];
             $state_model->country_id = $country_model->id;
             $state_model->save();
             $city_model = new City();
             $city_model->city_name = $_POST['Organization']['city'];
             $city_model->country_id = $country_model->id;
             $city_model->state_id = $state_model->state_id;
             $city_model->save();
             $model->attributes = $_POST['Organization'];
             $model->organization_created_by = 1;
             $model->organization_creation_date = new CDbExpression('NOW()');
             $model->city = $city_model->city_id;
             $model->state = $state_model->state_id;
             $model->country = $country_model->id;
             if ($model->save(false)) {
                 $user->user_organization_email_id = $model->email;
                 $user->user_password = md5($model->email . $model->email);
                 $user->user_type = 'admin';
                 $user->user_created_by = 1;
                 $user->user_creation_date = new CDbExpression('NOW()');
                 $user->user_organization_id = $model->organization_id;
                 $user->save();
                 $auth_assign->itemname = 'SuperAdmin';
                 $auth_assign->userid = $user->user_id;
                 $auth_assign->save(false);
                 $this->redirect(array('redirectLogin'));
             }
         }
         $this->render('create_org', array('model' => $model));
     } else {
         Yii::app()->user->logout();
         $this->redirect(array('login'));
     }
 }
Esempio n. 19
0
 public function testWrite()
 {
     $this->store->touch();
     $state = new State($this->store, true);
     $this->assertTrue($state->isOpen());
     $this->assertTrue($state->isMutable());
     $data = array('a' => 'foo', 'b' => array('c' => 'bar'), 'd' => array(1, 2, array(1, 2), 4));
     $state->override = $data;
     $this->assertEquals($data, $state->toArray());
     $state->defaults = array('e' => array('f' => 2));
     $state->close();
     $state = new State($this->store, false);
     $this->assertEquals($data, $state->toArray());
     $state->close();
 }
Esempio n. 20
0
 public function load_states()
 {
     $country_id = $_POST['country_id'];
     $states = new State();
     if ($country_id > 0) {
         $states->where('country_id', $country_id);
     }
     $states->get();
     echo '<select name="state_id" class="form-control">';
     echo '<option value="">-- select state --</option>';
     foreach ($states as $key => $state_item) {
         echo '<option value="' . $state_item->id . '">' . $state_item->state_name . '</option>';
     }
     echo '</select>';
 }
Esempio n. 21
0
 public function getAdminForm()
 {
     if (empty($this->origincountry)) {
         $this->origincountry = (int) _xls_get_conf('DEFAULT_COUNTRY', 224);
     }
     return array('title' => 'Note: You can ' . CHtml::link('Set Product Restrictions', '#', array('class' => 'basic', 'id' => get_class($this))) . ' for this module.', 'elements' => array('label' => array('type' => 'text', 'maxlength' => 64), 'accnumber' => array('type' => 'text', 'maxlength' => 64), 'meternumber' => array('type' => 'text', 'maxlength' => 64), 'securitycode' => array('type' => 'text', 'maxlength' => 64), 'authkey' => array('type' => 'text', 'maxlength' => 64), 'originadde' => array('type' => 'text', 'maxlength' => 64), 'origincity' => array('type' => 'text', 'maxlength' => 64), 'originpostcode' => array('type' => 'text', 'maxlength' => 64), 'origincountry' => array('type' => 'dropdownlist', 'items' => CHtml::listData(Country::model()->findAllByAttributes(array('active' => 1), array('order' => 'sort_order,country')), 'id', 'country'), 'ajax' => array('type' => 'POST', 'url' => Yii::app()->controller->createUrl('ajax/getstates'), 'data' => 'js:{"' . 'country_id' . '": $("#' . CHtml::activeId($this, 'origincountry') . ' option:selected").val()}', 'update' => '#' . CHtml::activeId($this, 'originstate'))), 'originstate' => array('type' => 'dropdownlist', 'items' => CHtml::listData(State::model()->findAllByAttributes(array('country_id' => $this->origincountry, 'active' => 1), array('order' => 'sort_order,state')), 'id', 'code')), 'offerservices' => array('type' => 'checkboxlist', 'items' => fedex::$service_types, 'separator' => '', 'template' => '<div class="offerservices">{input} {label}</div>', 'label' => 'Offer these services<br><a onclick="selectall()">Select All</a><br><a onclick="selectnone()">Select None</a><br>'), 'packaging' => array('type' => 'dropdownlist', 'items' => array('YOUR_PACKAGING' => 'Your packaging', 'FEDEX_BOX' => 'FedEx Box', 'FEDEX_PAK' => 'FedEx Pak', 'FEDEX_TUBE' => 'FedEx Tube')), 'ratetype' => array('type' => 'dropdownlist', 'items' => array('RATED_LIST' => 'List Rates', 'RATED_ACCOUNT' => 'Negotiated rates')), 'customs' => array('type' => 'dropdownlist', 'items' => array('CLEARANCEFEE' => 'FedEx Handles Customs Clearance', 'NOCHARGE' => 'My store handles Customs Clearance')), 'restrictcountry' => array('type' => 'dropdownlist', 'items' => Country::getAdminRestrictionList(true)), 'markup' => array('type' => 'text', 'maxlength' => 4), 'product' => array('type' => 'text', 'maxlength' => 64)));
 }
Esempio n. 22
0
 /**
  * (Web service method) Notify WordPress that the bot is online.
  * @param  mixed[] $args an empty array
  * @return mixed[] status; error_message
  */
 private function web_checkin($args)
 {
     $state = State::get_instance();
     $state->last_checkin_utc = gmmktime();
     $state->save();
     return array('status' => 'ok', 'error_message' => '');
 }
Esempio n. 23
0
 function updateAction()
 {
     $model = new Address();
     // Uncomment the following line if AJAX validation is needed
     $this->performAjaxValidation($model);
     if (isset($_POST['ajax']) && $_POST['ajax'] == 'categorys-form') {
         if (isset($_POST['AFID_ALL']) || isset($_POST['AFID']) && !$_POST['AFID']) {
             $_POST['AFID'] = NULL;
         }
         $model->fillFromArray($_POST, FALSE);
         $model->user_id_updated = $this->user->user_id;
         $model->updated = 'NOW():sql';
         $model->model_uset_id = $this->user->user_id;
         if ($model->save()) {
             Message::echoJsonSuccess(__('address_updated'));
         } else {
             Message::echoJsonError(__('address_not_updated'));
         }
         die;
     }
     $id = AF::get($this->params, 'id', FALSE);
     if (!$id) {
         throw new AFHttpException(0, 'no_id');
     }
     if (!$model->findByPk($id)) {
         throw new AFHttpException(0, 'incorrect_id');
     }
     $countries = Country::model()->cache()->findAllInArray();
     $states = $model->country_id ? State::model()->getStatesByCID($model->country_id) : array();
     $this->addToPageTitle('Update address');
     Assets::js('jquery.form');
     $this->render('update', array('model' => $model, 'countries' => $countries, 'states' => $states));
 }
Esempio n. 24
0
 public function initialize($entity = null, $options = null)
 {
     $country = new Select('countryid', Country::find(), array('using' => array('id', 'country'), 'useEmpty' => TRUE, 'emptyText' => $this->di->get('translate')->_('Seleccione un País')));
     $country->setLabel('País');
     $this->add($country);
     if (isset($entity)) {
         if ($entity->getCountryid()) {
             $state = new Select('stateid', State::find(array("columns" => array("id,state"), "conditions" => "countryid =:countryid:", "bind" => array("countryid" => $entity->countryid))), array("useEmpty" => true, "emptyText" => $this->di->get('translate')->_('Seleccione un Estado'), 'using' => array('id', 'state')));
             $state->setLabel('Estado');
             $this->add($state);
             $city = new Select('cityid', City::find(array("columns" => array("id,city"), "conditions" => "countryid =:countryid: AND stateid =:stateid: ", "bind" => array("countryid" => $entity->countryid, "stateid" => $entity->stateid))), array("useEmpty" => true, "emptyText" => $this->di->get('translate')->_('Seleccione una ciudad'), 'using' => array('id', 'city')));
             $city->setLabel('Ciudad');
             $this->add($city);
             $township = new Select('townshipid', Township::find(array("columns" => array("id,township"), "conditions" => "cityid =:cityid:", "bind" => array("cityid" => $entity->cityid))), array("useEmpty" => true, "emptyText" => $this->di->get('translate')->_('Seleccione un Sector'), 'using' => array('id', 'township')));
             $township->setLabel('Sector');
             $this->add($township);
             $neighborhood = new Select('neighborhoodid', Neighborhood::find(array("columns" => array("id,neighborhood"), "conditions" => "cityid =:cityid:", "bind" => array("cityid" => $entity->cityid))), array("useEmpty" => true, "emptyText" => $this->di->get('translate')->_('Seleccione un Barrio'), 'using' => array('id', 'neighborhood')));
             $neighborhood->setLabel('Barrio');
             $this->add($neighborhood);
         } else {
             $this->set_empty_values();
         }
     } else {
         $this->set_empty_values();
     }
     $address = new Textarea('address', array("maxlength" => "400"));
     $address->setLabel('Dirección');
     $this->add($address);
     $description = new Textarea('description', array("maxlength" => "100"));
     $description->setLabel('Descripción');
     $this->add($description);
 }
Esempio n. 25
0
 public function getAdminForm()
 {
     if (empty($this->origincountry)) {
         $this->origincountry = (int) _xls_get_conf('DEFAULT_COUNTRY', 224);
     }
     return array('title' => 'Note: You can ' . CHtml::link('Set Product Restrictions', '#', array('class' => 'basic', 'id' => get_class($this))) . ' for this module.', 'elements' => array('label' => array('type' => 'text', 'maxlength' => 64), 'mode' => array('type' => 'dropdownlist', 'items' => array('UPS' => 'Domestic US UPS Mode', 'IUPS' => 'IUPS International UPS Mode')), 'username' => array('type' => 'text', 'maxlength' => 64), 'password' => array('type' => 'text', 'maxlength' => 64), 'accesskey' => array('type' => 'text', 'maxlength' => 64), 'originpostcode' => array('type' => 'text', 'maxlength' => 64), 'origincountry' => array('type' => 'dropdownlist', 'items' => CHtml::listData(Country::model()->findAllByAttributes(array('active' => 1), array('order' => 'sort_order,country')), 'id', 'country'), 'ajax' => array('type' => 'POST', 'url' => Yii::app()->controller->createUrl('ajax/getstates'), 'data' => 'js:{"' . 'country_id' . '": $("#' . CHtml::activeId($this, 'origincountry') . ' option:selected").val()}', 'update' => '#' . CHtml::activeId($this, 'originstate'))), 'originstate' => array('type' => 'dropdownlist', 'items' => CHtml::listData(State::model()->findAllByAttributes(array('country_id' => $this->origincountry, 'active' => 1), array('order' => 'sort_order,state')), 'id', 'code')), 'offerservices' => array('type' => 'checkboxlist', 'items' => ups::$service_types, 'separator' => '', 'template' => '<div class="offerservices">{input} {label}</div>', 'label' => 'Offer these services<br><a onclick="selectall()">Select All</a><br><a onclick="selectnone()">Select None</a><br>'), 'package' => array('type' => 'dropdownlist', 'items' => ups::$package_types), 'ratecode' => array('type' => 'dropdownlist', 'items' => ups::$rate_types), 'customerclassification' => array('type' => 'dropdownlist', 'items' => array('04' => 'Retail', '03' => 'Occasional', '01' => 'Wholesale')), 'restrictcountry' => array('type' => 'dropdownlist', 'items' => Country::getAdminRestrictionList(true)), 'markup' => array('type' => 'text', 'maxlength' => 4), 'product' => array('type' => 'text', 'maxlength' => 64)));
 }
Esempio n. 26
0
 /**
  * Validates that the state that the customer enters either
  * in the shipping form or billing form respects the format
  * for the countries we want to validate it upon.
  *
  * @param CModel $model
  * @param string $attribute
  * @return void
  */
 public function validateAttribute($model, $attribute)
 {
     switch ($attribute) {
         case 'shippingState':
             $objCountry = Country::Load($model->shippingCountry);
             break;
         case 'billingState':
             $objCountry = Country::Load($model->billingCountry);
             break;
         default:
             // Cannot validate any other attributes.
             return;
     }
     if ($objCountry === null) {
         // Country isn't valid, can't validate the state!
         return;
     }
     $countriesToValidateState = array(self::USA, self::CANADA, self::AUSTRALIA);
     if (in_array($objCountry->id, $countriesToValidateState) === false) {
         // Do not attempt to validate the state.
         return;
     }
     if (empty($model->{$attribute}) === true) {
         $this->addError($model, $attribute, Yii::t('yii', '{attributeName} cannot be blank.', array('{attributeName}' => $model->getattributeLabel($attribute))));
     } else {
         $objState = State::Load($model->{$attribute});
         if ($objState === null) {
             $this->addError($model, $attribute, Yii::t('yii', '{attributeName} is invalid.', array('{attributeName}' => $model->getattributeLabel($attribute))));
         }
     }
 }
Esempio n. 27
0
function event_shutdown()
{
    State::$handle_updates = false;
    if (State::$users_leaving_probation) {
        set_time_limit(0);
    }
    $ia = elgg_set_ignore_access(true);
    $force_private = elgg_get_plugin_setting(QUARANTINE_PRIVATE, PLUGIN_ID);
    foreach (State::$entities_quarantined as $entity) {
        if ($entity->{ORIGINAL_ACCESS_ID} === null || $entity->access_id != ACCESS_PRIVATE) {
            $entity->{ORIGINAL_ACCESS_ID} = $entity->access_id;
        }
        if ($force_private) {
            $entity->access_id = ACCESS_PRIVATE;
        } elseif ($entity->access_id == ACCESS_PUBLIC) {
            $entity->access_id = ACCESS_LOGGED_IN;
        }
        $entity->save();
    }
    foreach (State::$users_leaving_probation as $user) {
        $options = ['owner_guid' => $user->guid, 'metadata_name' => QUARANTINED, 'metadata_value' => '1', 'limit' => 0];
        $batch = new \ElggBatch('elgg_get_entities_from_metadata', $options, null, 25, false);
        foreach ($batch as $object) {
            /* @var \ElggObject $object */
            approve_content($object);
        }
    }
    elgg_set_ignore_access($ia);
}
 /**
  * Default action in default controller
  */
 public function action_index()
 {
     // get acl
     $acl = Acl::instance();
     // get first allowed module
     // get modules
     $modules = Settings::factory('modules')->as_array();
     $modules = array_keys($modules);
     $module = State::instance()->get('active.module');
     if ($module !== FALSE && $module !== 'Default') {
         if ($acl->allowed($module, 'access', FALSE, $this->_website) === TRUE) {
             $url = URL::to($module, array('website' => $this->_website));
             $this->redirect($url);
             exit;
         }
     }
     // find the first allowed module & redirect
     foreach ($modules as $module) {
         if ($acl->allowed($module, 'access', FALSE, $this->_website) === TRUE) {
             $url = URL::to($module, array('website' => $this->_website));
             $this->redirect($url);
             exit;
         }
     }
 }
Esempio n. 29
0
 public function personalinfo()
 {
     $driver = User::first(array('id = ?' => $this->user->id));
     if ($driver->cab_driver == 1) {
         $view = $this->getActionView();
         $states = State::all();
         $countries = Country::all();
         $driver = CabDriver::first(array('user_id = ?' => $this->user->id));
         $view->set('states', $states)->set('countries', $countries)->set('driver', $driver);
         if (RequestMethods::post('full_name')) {
             $driver->full_name = RequestMethods::post('full_name');
             $driver->contact = RequestMethods::post('contact');
             $driver->country = RequestMethods::post('country');
             $driver->state = RequestMethods::post('state');
             $driver->pincode = RequestMethods::post('pin');
             $driver->address = RequestMethods::post('address');
             $driver->pinfo_flag = '1';
             if ($driver->validate()) {
                 $driver->save();
                 header("Location: /driver/vehicleinfo");
             } else {
                 $view->set('error', "validation  not good");
             }
         }
     } else {
         header('/');
     }
 }
Esempio n. 30
0
 public function packages()
 {
     $view = $this->getActionView();
     $states = State::all();
     $view->set('states', $states);
     $source = RequestMethods::get('source');
     $source_state = State::first(array('id = ?' => $source));
     $dest = RequestMethods::get('dest');
     $dest_state = State::first(array('id = ?' => $dest));
     $month = RequestMethods::get('month');
     $year = RequestMethods::get('year');
     $page = RequestMethods::get('page', 1);
     $limit = 9;
     if (RequestMethods::get('source')) {
         $count = Package::count(array('source Like ?' => $source, 'destination Like ?' => $dest, 'month = ?' => $month, 'year = ?' => $year));
         $total_pages = $count / 9 + 1;
         for ($i = 1; $i <= $total_pages; $i++) {
             $pages[$i] = $i;
         }
         $packages = Package::all(array('source Like ?' => $source, 'destination Like ?' => $dest, 'month = ?' => $month, 'year = ?' => $year, 'live = ?' => 1), array("*"), null, null, $limit, $page);
         $view->set('n', 'http://planyourtours.io/travels/packages?source=' . $source . '&dest=' . $dest . '&type=Group&month=' . $month . '&year=' . $year . '&page=')->set('source', $source_state)->set('dest', $dest_state)->set('month', $month)->set('year', $year);
     } else {
         $count = Package::count();
         $total_pages = $count / 9 + 1;
         for ($i = 1; $i <= $total_pages; $i++) {
             $pages[$i] = $i;
         }
         $packages = Package::all(array('live = ?' => 1), array("*"), null, null, $limit, $page);
         $view->set('n', 'http://planyourtours.io/travels/packages?&page=');
     }
     if (!empty($packages)) {
         $view->set('packages', $packages)->set('pages', $pages);
     }
 }