Example #1
0
 public function addSectionAction()
 {
     if ($this->request->isPost() == true) {
         $ans = [];
         $sectionName = $this->request->getPost("name");
         $existSection = Section::find(array("conditions" => "name=?1", "bind" => array(1 => $sectionName)));
         if (count($existSection) == 0) {
             $section = new Section();
             $section->name = $sectionName;
             if ($section->save()) {
                 $ans['id'] = $section->id;
                 echo json_encode($ans);
             } else {
                 foreach ($section->getMessages() as $message) {
                     throw new BaseException($message, 100);
                 }
             }
         } else {
             throw new BaseException('栏目已存在', 101);
         }
         /* try {
         
         
                     } catch (BaseException $e) {
         
                     }*/
     }
 }
 protected function validate()
 {
     $required = array("class_level" => "Class", "section" => "Section", "code" => "Code");
     global $user;
     if ($user->checkAdmin() == true) {
         if (isset($_POST)) {
             foreach ($required as $key => $value) {
                 if (!isset($_POST[$key]) || $_POST[$key] == '' || $_POST[$key] == 'select') {
                     echo $value . ' is Required<br/>';
                     return;
                 }
             }
             echo 'Saving...';
             global $objPDO;
             require_once $_SERVER['DOCUMENT_ROOT'] . '/cloud/model/section_class.php';
             $section = new Section($objPDO);
             $section->setClass($_POST['class_level']);
             $section->setSection($_POST['section']);
             $section->setCode($_POST['code']);
             $section->save();
             echo '<meta http-equiv="Refresh" content="0;url=http://localhost/cloud/miscellaneous"/>';
         }
     } else {
         header('Location:http://localhost/cloud');
     }
 }
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aSection !== null) {
             if ($this->aSection->isModified() || $this->aSection->isNew()) {
                 $affectedRows += $this->aSection->save($con);
             }
             $this->setSection($this->aSection);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
Example #4
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Section();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Section'])) {
         $model->attributes = $_POST['Section'];
         if ($model->save()) {
             $orgs = isset($_POST['Section']['Organization']) ? $_POST['Section']['Organization'] : array();
             $model->saveRelationOrganizations($orgs, $model->id);
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
Example #5
0
 public static function add($name, $description = "", $grantAdmin = true)
 {
     $sectionManager = new Section();
     if ($sectionManager->rowCount(array('label' => $name)) == 0) {
         $sectionManager->setLabel($name);
         $sectionManager->setDescription($description);
         $sectionManager->save();
         if ($grantAdmin) {
             $right = new Right();
             $right = $right->load(array('section' => $sectionManager->getLabel(), 'rank' => 1));
             $right = !$right ? new Right() : $right;
             $right->setSection($sectionManager->getId());
             $right->setCreate(1);
             $right->setRead(1);
             $right->setUpdate(1);
             $right->setDelete(1);
             $right->setRank(1);
             $right->save();
         }
     }
 }
Example #6
0
 function _saveSections()
 {
     require_once 'AMP/Content/Section.inc.php';
     $section_count = 1;
     $form =& $this->get_form();
     while (isset($this->_request_vars[$this->_get_section_fieldname($section_count)]) && $this->_request_vars[$this->_get_section_fieldname($section_count)]) {
         $name = $this->_request_vars[$this->_get_section_fieldname($section_count)];
         $text = $this->_request_vars[$this->_get_section_fieldname($section_count, 'text')];
         $section = new Section(AMP_Registry::getDbcon());
         $section->setName($name);
         $section->setBlurb($text);
         $section->setParent();
         $section->setListType();
         if (!($result = $section->save())) {
             ++$section_count;
             continue;
         }
         $section->publish();
         $section->reorder($section_count);
         $form->setValues(array($this->_get_section_fieldname($section_count) => '', $this->_get_section_fieldname($section_count, 'text') => ''));
         $this->message(sprintf(AMP_TEXT_DATA_SAVE_SUCCESS, $section->getName()));
         ++$section_count;
     }
 }
 public function buildDataXML($data)
 {
     $section_xml = $this->document->createElement('section');
     $section_xml->setAttribute('handle', $this->section->handle);
     $filter = $filter_value = $where = $joins = NULL;
     $current_page = isset($_REQUEST['pg']) && is_numeric($_REQUEST['pg']) ? max(1, intval($_REQUEST['pg'])) : 1;
     $current_filter = $filter ? "&filter={$field_handle}:{$filter_value}" : '';
     if (isset($_REQUEST['sort']) && is_string($_REQUEST['sort'])) {
         $sort = $_REQUEST['sort'];
         $order = $_REQUEST['order'] ? strtolower($_REQUEST['order']) : 'asc';
         if ($this->section->{'publish-order-handle'} != $sort || $this->section->{'publish-order-direction'} != $order) {
             $this->section->{'publish-order-handle'} = $sort;
             $this->section->{'publish-order-direction'} = $order;
             $errors = new MessageStack();
             Section::save($this->section, $errors);
             redirect($url . $current_filter);
         }
     } elseif (isset($_REQUEST['unsort'])) {
         $section->{'publish-order-handle'} = null;
         $section->{'publish-order-direction'} = null;
         $errors = new MessageStack();
         Section::save($section, $errors);
         redirect($URL);
     }
     $fields_xml = $this->document->createElement('fields');
     foreach ($this->section->fields as $column) {
         if ($column->{'show-column'} == 'yes') {
             $field = $this->document->createElement('field', $column->name);
             $field->setAttribute('handle', $column->{'element-name'});
             $fields_xml->appendChild($field);
         }
     }
     $section_xml->appendChild($fields_xml);
     try {
         $entry_count = Symphony::Database()->query("SELECT COUNT(id) as `count` FROM `tbl_entries` WHERE `section` = '%s'", array($section->handle))->current()->count;
     } catch (DatabaseException $ex) {
     }
     $pagination_xml = $this->document->createElement('pagination');
     $pagination_xml->appendChild($this->document->createElement('total-entries', $entry_count));
     $pagination_xml->appendChild($this->document->createElement('per-page', Symphony::Configuration()->core()->symphony->{'pagination-maximum-rows'}));
     $pagination_xml->appendChild($this->document->createElement('total-pages', ceil($entry_count / Symphony::Configuration()->core()->symphony->{'pagination-maximum-rows'})));
     $pagination_xml->appendChild($this->document->createElement('current-page', $current_page));
     $section_xml->appendChild($pagination_xml);
     // Simplified/messy entry fetching
     $entries = Symphony::Database()->query("SELECT * FROM `tbl_entries` WHERE `section` = '%s' ORDER BY `id` ASC", array($this->section->handle), 'EntryResult');
     $entries_xml = $this->document->createElement('entries');
     foreach ($entries as $entry) {
         $entry_xml = $this->document->createElement('entry');
         $entry_xml->setAttribute('id', $entry->id);
         $fields_xml = $this->document->createElement('fields');
         foreach ($this->section->fields as $column) {
             if ($column->{'show-column'} != 'yes') {
                 continue;
             }
             $field_handle = $column->{'element-name'};
             $fields_xml->appendChild($this->document->createElement($field_handle, $entry->data()->{$field_handle}->value));
         }
         $entry_xml->appendChild($fields_xml);
         $entries_xml->appendChild($entry_xml);
     }
     $section_xml->appendChild($entries_xml);
     $data->appendChild($section_xml);
 }
 /**
  * edit section in system (the action page)
  * 
  * @return void
  */
 public function editaction()
 {
     $s = new Section($this->input->post('id'));
     $s->name = $this->input->post('name');
     $s->view = $this->input->post('view');
     $s->save();
     redirect('section_editor');
 }
Example #9
0
 function _checkNewSection($data, $fieldname)
 {
     if (!(isset($data['new_section_name']) && $data['new_section_name'])) {
         if (!isset($data[$fieldname])) {
             return false;
         }
         return $data[$fieldname];
     }
     require_once 'AMP/Content/Section.inc.php';
     $section = new Section(AMP_Registry::getDbcon());
     $section->setDefaults();
     $section->setName($data['new_section_name']);
     $section->setParent($data['new_section_parent']);
     if (!($result = $section->save())) {
         return $data[$fieldname];
     }
     $section->publish();
     $flash =& AMP_System_Flash::instance();
     $flash->add_message(sprintf(AMP_TEXT_DATA_SAVE_SUCCESS, $section->getName()));
     return $section->id;
 }
Example #10
0
 function install()
 {
     $CI =& get_instance();
     $CI->load->dbforge();
     // loading objects;
     $CI->config->load('objects');
     $tables = $CI->config->item('objects');
     $tables_keys = array_keys($tables);
     foreach ($tables_keys as $item) {
         $CI->dbforge->add_field($tables[$item]);
         $CI->dbforge->create_table($item);
         $CI->db->query("ALTER TABLE `" . $item . "` ADD COLUMN `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, ADD PRIMARY KEY (`id`)");
     }
     $CI->load->library('datamapper');
     //adding the default section
     $index = new Section();
     $index->parent_section = 0;
     $index->sort = 0;
     $index->save();
     $page_body = new Content();
     $page_body->sub_section = intval(TRUE);
     $page_body->cell = 0;
     $page_body->sort = 0;
     $page_body->parent_section = $index->id;
     $page_body->info = 'PAGE_BODY_LOCKED';
     $page_body->save();
     $default_layout = new Content();
     $default_layout->path = 'default.php';
     $default_layout->parent_content = 1;
     $default_layout->parent_section = 1;
     $default_layout->subsection = 0;
     $default_layout->cell = 0;
     $default_layout->sort = 0;
     $default_layout->save();
 }
Example #11
0
 $configuration->put('COOKIE_LIFETIME', '7');
 $configuration->put('VOCAL_ENTITY_NAME', 'YANA');
 $configuration->put('PROGRAM_VERSION', '3.0.6');
 $configuration->put('HOME_PAGE', 'index.php');
 $configuration->put('VOCAL_SENSITIVITY', '0.0');
 //Création du rang admin
 $rank = new Rank();
 $rank->setLabel('admin');
 $rank->save();
 //Déclaration des sections du programme
 $sections = array('event', 'vocal', 'user', 'plugin', 'configuration', 'admin');
 //Création des sections déclarées et attribution de tous les droits sur toutes ces sections pour l'admin
 foreach ($sections as $sectionName) {
     $s = new Section();
     $s->setLabel($sectionName);
     $s->save();
     $r = new Right();
     $r->setSection($s->getId());
     $r->setRead('1');
     $r->setDelete('1');
     $r->setCreate('1');
     $r->setUpdate('1');
     $r->setRank($rank->getId());
     $r->save();
 }
 $personalities = array('John Travolta', 'Jeff Buckley', 'Tom Cruise', 'John Lennon', 'Emmet Brown', 'Geo trouvetou', 'Luke Skywalker', 'Mac Gyver', 'Marty McFly');
 $im = $personalities[rand(0, count($personalities) - 1)];
 list($fn, $n) = explode(' ', $im);
 //Creation du premier compte et assignation en admin
 $user->setMail($_POST['email']);
 $user->setPassword($_POST['password']);
Example #12
0
 public function make($section_title, $content, $title, $url, $nsfw, $nsfl, Section $section)
 {
     $section_title = strtolower($section_title);
     $block = new SuccessBlock();
     $block->data->section_title = $section_title;
     $block->data->item_title = Utility::prettyUrl($title);
     if ($block->success) {
         if (Auth::user()->points < 1) {
             $block->success = false;
             $block->errors[] = 'You need at least one point to post';
         }
     }
     if ($block->success) {
         if (!$this->canPost()) {
             $block->success = false;
             $block->errors[] = 'can only post ' . Utility::availablePosts() . ' per day';
         }
     }
     if ($block->success) {
         $data = $this->prepareData(['data' => $content, 'title' => $title, 'url' => $url, 'user_id' => Auth::user()->id, 'nsfw' => $nsfw, 'nsfl' => $nsfl]);
         $rules = $this->generateRules($data);
         $validate = Validator::make($data, $this->generateRules($data));
         if ($validate->fails()) {
             $block->success = false;
             foreach ($validate->messages()->all() as $v) {
                 $block->errors[] = $v;
             }
         }
     }
     if ($block->success) {
         //check if .gif & gfycat it
         $data['url'] = $this->gfycatUrl($data['url']);
         if (!$section->exists($section_title)) {
             $ssect = new Section(['title' => $section_title]);
             if (!$ssect->save()) {
                 $block->success = false;
                 $block->errors[] = 'unable to create new spreadit';
                 $block->data->section_title = str_replace(' ', '_', $block->data->section_title);
             }
         }
     }
     if ($block->success) {
         $section = $section->sectionFromSections($section->getByTitle(Utility::splitByTitle($section_title)));
         if ($section->id < 1) {
             $block->success = false;
             $block->errors[] = 'can only post to a real section(you probably tried to post to /s/all)';
         }
     }
     if ($block->success) {
         $data['section_id'] = $section->id;
         $item = new Post($data);
         $item->save();
         if (isset($rules['url'])) {
             if (Utility::urlExists($data['url'])) {
                 Utility::thumbnailScript($item->id, $data['url']);
             }
         }
         //add a point for adding posts
         if (Auth::user()->anonymous == 0) {
             Auth::user()->increment('points');
         }
         $block->data->item_id = $item->id;
     } else {
         $block->data->item_id = null;
     }
     return $block;
 }
Example #13
0
	Le code contenu dans cette page ne sera éxecuté qu'à l'activation du plugin 
	Vous pouvez donc l'utiliser pour créer des tables SQLite, des dossiers, ou executer une action
	qui ne doit se lancer qu'à l'installation ex :
*/
require_once 'Sensor.class.php';
$table = new Sensor();
$table->create();
require_once 'SensorType.class.php';
$table2 = new SensorType();
$table2->create();
$s1 = new Section();
$s1->setLabel('sensor');
$s1->save();
$s2 = new Section();
$s2->setLabel('sensortypes');
$s2->save();
$r1 = new Right();
$r1->setSection($s1->getId());
$r1->setRead('1');
$r1->setDelete('1');
$r1->setCreate('1');
$r1->setUpdate('1');
$r1->setRank('1');
$r1->save();
$r2 = new Right();
$r2->setSection($s2->getId());
$r2->setRead('1');
$r2->setDelete('1');
$r2->setCreate('1');
$r2->setUpdate('1');
$r2->setRank('1');
 private function __save(array $essentials = null, array $fields = null, array $layout = null, Section $section = null)
 {
     if (is_null($section)) {
         $section = new Section();
         $section->path = SECTIONS;
     }
     $this->section = $section;
     $this->errors = new MessageStack();
     $old_handle = false;
     if (is_array($essentials)) {
         if ($essentials['name'] !== $this->section->name and $this->section->name != '') {
             $old_handle = $this->section->handle;
         }
         $this->section->name = $essentials['name'];
         $this->section->{'navigation-group'} = $essentials['navigation-group'];
         $this->section->{'hidden-from-publish-menu'} = isset($essentials['hidden-from-publish-menu']) && $essentials['hidden-from-publish-menu'] == 'yes' ? 'yes' : 'no';
     }
     // Resave fields:
     if (!is_null($fields)) {
         $this->section->removeAllFields();
         if (is_array($fields) and !empty($fields)) {
             foreach ($fields as $field) {
                 $this->section->appendFieldByType($field['type'], $field);
             }
         }
     }
     // Resave layout:
     if (!is_null($layout)) {
         foreach ($layout as &$column) {
             $column = (object) $column;
             if (is_array($column->fieldsets)) {
                 foreach ($column->fieldsets as &$fieldset) {
                     $fieldset = (object) $fieldset;
                 }
             }
         }
         $this->section->layout = $layout;
     }
     try {
         $callback = Administration::instance()->getPageCallback();
         $current_page = $callback['pageroot'] . $callback['context'][0] . '/';
         ###
         # Delegate: SectionPreSave
         Extension::notify('SectionPreSave', $current_page, array('section' => &$this->section, 'errors' => &$this->errors));
         Section::save($this->section, $this->errors);
         ###
         # Delegate: SectionPostSave
         Extension::notify('SectionPostSave', $current_page, array('section' => &$this->section, 'errors' => &$this->errors));
         // Rename section:
         if ($old_handle !== false) {
             Section::rename($this->section, $old_handle);
             ###
             # Delegate: SectionPostRename
             Extension::notify('SectionPostRename', $current_page, array('section' => &$this->section, 'old-handle' => $old_handle, 'errors' => &$this->errors));
         }
         Section::synchronise($this->section);
         return true;
     } catch (SectionException $e) {
         switch ($e->getCode()) {
             case Section::ERROR_MISSING_OR_INVALID_FIELDS:
                 $this->alerts()->append(__('Could not save the layout, there are errors in your field configuration. <a class="more">More information.</a>'), AlertStack::ERROR, $this->errors);
                 break;
             case Section::ERROR_FAILED_TO_WRITE:
                 $this->alerts()->append($e->getMessage(), AlertStack::ERROR);
                 break;
         }
     } catch (Exception $e) {
         $this->alerts()->append(__('An unknown error has occurred. <a class="more">Show trace information.</a>'), AlertStack::ERROR, $e);
     }
     return false;
 }
Example #15
0
 function showEditSectionRes()
 {
     $displaySysAdmin = new DisplaySysAdmin();
     $survey = new Survey($_SESSION['SUID']);
     $seid = getFromSessionParams('seid');
     $content = "";
     if ($seid != '') {
         //edit
         $section = $survey->getSection($seid);
         $_SESSION['SEID'] = $seid;
         $content = $displaySysAdmin->displaySuccess(Language::messageSectionChanged(loadvar(SETTING_NAME)));
     } else {
         //add section!
         if (loadvar(SETTING_NAME) != "") {
             $section = new Section();
             $section->setSuid($_SESSION['SUID']);
             $content = $displaySysAdmin->displaySuccess(Language::messageSectionAdded(loadvar(SETTING_NAME)));
         }
     }
     $checker = new Checker($_SESSION['SUID']);
     if ($seid == '') {
         $checks = $checker->checkName(loadvar(SETTING_NAME));
         if (sizeof($checks) > 0) {
             $content = implode("<br/>", $checks);
             return $this->showAddSection($content);
         }
     }
     //ADD ALL SORTS OF CHECKS!!
     if ($seid != '' || loadvar(SETTING_NAME) != "") {
         $section->setName(trim(loadvar(SETTING_NAME)));
         $section->setDescription(loadvar(SETTING_DESCRIPTION));
         $section->setHidden(loadvar(SETTING_HIDDEN));
         $section->setHeader(loadvarAllowHTML(SETTING_SECTION_HEADER));
         $section->setFooter(loadvarAllowHTML(SETTING_SECTION_FOOTER));
         $section->save();
         $checks = $checker->checkSection($section);
         if (sizeof($checks) > 0) {
             $content .= $displaySysAdmin->displayError(implode("<br/>", $checks));
         }
     }
     /* compile */
     $compiler = new Compiler($_SESSION['SUID'], getSurveyVersion($survey));
     $mess = $compiler->generateSections(array($section));
     $mess = $compiler->generateGetFillsSections(array($section));
     $mess = $compiler->generateInlineFieldsSections(array($section));
     /* update last page */
     $_SESSION['LASTPAGE'] = substr($_SESSION['LASTPAGE'], 0, strripos($_SESSION['LASTPAGE'], "res"));
     if ($seid != '') {
         return $displaySysAdmin->showEditSection($_SESSION['SEID'], $content);
     } else {
         return $displaySysAdmin->showSurvey($content);
     }
 }
Example #16
0
 public function duplicatecvpage($cv_code)
 {
     $cv_old = Cv::where('cv_code', $cv_code)->first();
     if ($cv_old->user_id != Auth::id()) {
         return 'False';
     }
     $new_cv_name = $cv_old->cv_name . ' - Copy';
     $cv = new Cv();
     do {
         $random = str_random(10);
         $count = Cv::where('cv_code', $random)->count();
     } while ($count != 0);
     $cv->cv_code = $random;
     if (Auth::check()) {
         $cv->user_id = Auth::id();
     }
     $cv->cv_name = $new_cv_name;
     $cv->user_id = $cv_old->user_id;
     $cv->full_name = $cv_old->full_name;
     $cv->phone_num = $cv_old->phone_num;
     $cv->email = $cv_old->email;
     $cv->website = $cv_old->website;
     $cv->add_line1 = $cv_old->add_line1;
     $cv->add_line2 = $cv_old->add_line2;
     $cv->dob = $cv_old->dob;
     $cv->marital_status = $cv_old->marital_status;
     $cv->profile_image = $cv_old->profile_image;
     $cv->sex = $cv_old->sex;
     $cv->state_origin = $cv_old->state_origin;
     $cv->religion = $cv_old->religion;
     $cv->religion_text = $cv_old->religion_text;
     $cv->show_profile_pic = $cv_old->show_profile_pic;
     $cv->local_government = $cv_old->local_government;
     $cv->save();
     $new_cv_id = $cv->id;
     // copying sections
     $sections = Section::where('cv_id', $cv_old->id)->get();
     foreach ($sections as $section) {
         $section_new = new Section();
         $section_new->cv_id = $new_cv_id;
         $section_new->section_name = $section->section_name;
         $section_new->type = $section->type;
         $section_new->content = $section->content;
         $section_new->default = $section->default;
         $section_new->priority = $section->priority;
         $section_new->save();
     }
     // copying educations
     $educations = Education::where('cv_id', $cv_old->id)->get();
     foreach ($educations as $education) {
         $education_new = new Education();
         $education_new->cv_id = $new_cv_id;
         $education_new->coursename = $education->coursename;
         $education_new->institutename = $education->institutename;
         $education_new->add_line1 = $education->add_line1;
         $education_new->add_line2 = $education->add_line2;
         $education_new->startdate = $education->startdate;
         $education_new->enddate = $education->enddate;
         $education_new->otherinfo = $education->otherinfo;
         $education_new->priority = $education->priority;
         $education_new->save();
     }
     // copying languages
     $languages = Language::where('cv_id', $cv_old->id)->get();
     foreach ($languages as $language) {
         $language_new = new Language();
         $language_new->cv_id = $new_cv_id;
         $language_new->language_id = $language->language_id;
         $language_new->language_name = $language->language_name;
         $language_new->ability_id = $language->ability_id;
         $language_new->level_id = $language->level_id;
         $language_new->priority = $language->priority;
         $language_new->save();
     }
     // copying nysc
     $nyscs = Nysc::where('cv_id', $cv_old->id)->get();
     foreach ($nyscs as $nysc) {
         $nysc_new = new Nysc();
         $nysc_new->cv_id = $new_cv_id;
         $nysc_new->year = $nysc->year;
         $nysc_new->batch = $nysc->batch;
         $nysc_new->ppa = $nysc->ppa;
         $nysc_new->cd = $nysc->cd;
         $nysc_new->otherinfo = $nysc->otherinfo;
         $nysc_new->priority = $nysc->priority;
         $nysc_new->save();
     }
     // copying work_exp
     $work_exps = WorkExperience::where('cv_id', $cv_old->id)->get();
     foreach ($work_exps as $work_exp) {
         $work_exp_new = new WorkExperience();
         $work_exp_new->cv_id = $new_cv_id;
         $work_exp_new->title = $work_exp->title;
         $work_exp_new->company = $work_exp->company;
         $work_exp_new->location = $work_exp->location;
         $work_exp_new->startdate = $work_exp->startdate;
         $work_exp_new->enddate = $work_exp->enddate;
         $work_exp_new->otherinfo = $work_exp->otherinfo;
         $work_exp_new->priority = $work_exp->priority;
         $work_exp_new->save();
     }
     return Redirect::back();
 }
 public function defineFields($id)
 {
     $template = $this->template->findOrFail($id);
     $file = $template->file;
     $fullpath = app_path() . '/views/uploads/layouts/' . $file;
     $string = file_get_contents($fullpath);
     $string = str_replace('@yield', '|@yield', $string);
     $strings = explode('|', $string);
     $pattern = "/@yield\\(\\'(.*?)\\'\\)/";
     foreach ($strings as $string) {
         if (preg_match($pattern, $string, $matches)) {
             $section = new Section();
             $section->title = $matches[1];
             $section->t_id = $id;
             $section->save();
         }
     }
     return Redirect::route('bladetemps.create', array('id' => $id));
 }
Example #18
0
<?php

require_once 'KodiCmd.class.php';
$table = new KodiCmd();
$table->create();
$s1 = new Section();
$s1->setLabel('kodi');
$s1->save();
$r1 = new Right();
$r1->setSection($s1->getId());
$r1->setRead('1');
$r1->setDelete('1');
$r1->setCreate('1');
$r1->setUpdate('1');
$r1->setRank('1');
$r1->save();
$conf = new Configuration();
$conf->put('plugin_kodiCmd_api_url_kodi', 'http://192.168.1.107:85/jsonrpc');
$conf->put('plugin_kodiCmd_api_timeout_kodi', 5);
$conf->put('plugin_kodiCmd_api_recognition_status', '');
$ro = new Room();
$ro->setName('KODI');
$ro->setDescription('De la bonne zic, un bon p\'tit film....');
$ro->save();
$roomManager = new Room();
$rooms = $roomManager->populate();
foreach ($rooms as $room) {
    if ($room->getName() == "KODI") {
        $kodiRoomId = $room->getId();
    }
}
 public function run()
 {
     DB::table('section')->delete();
     // WORKFLOW 1
     $sec = new Section();
     $sec->id = '1';
     $sec->section_order_id = '1';
     $sec->sectionName = 'PURCHASE REQUEST';
     $sec->workflow_id = '1';
     $sec->save();
     $sec = new Section();
     $sec->id = '2';
     $sec->section_order_id = '2';
     $sec->sectionName = 'BAC REQUIREMENTS';
     $sec->workflow_id = '1';
     $sec->save();
     $sec = new Section();
     $sec->id = '3';
     $sec->section_order_id = '3';
     $sec->sectionName = 'PURCHASE ORDER';
     $sec->workflow_id = '1';
     $sec->save();
     $sec = new Section();
     $sec->id = '4';
     $sec->section_order_id = '4';
     $sec->sectionName = 'VOUCHER';
     $sec->workflow_id = '1';
     $sec->save();
     // WORKFLOW 2
     $sec = new Section();
     $sec->id = '5';
     $sec->section_order_id = '1';
     $sec->sectionName = 'PURCHASE REQUEST';
     $sec->workflow_id = '2';
     $sec->save();
     $sec = new Section();
     $sec->id = '6';
     $sec->section_order_id = '2';
     $sec->sectionName = 'BAC REQUIREMENTS';
     $sec->workflow_id = '2';
     $sec->save();
     $sec = new Section();
     $sec->id = '7';
     $sec->section_order_id = '3';
     $sec->sectionName = 'PURCHASE ORDER';
     $sec->workflow_id = '2';
     $sec->save();
     $sec = new Section();
     $sec->id = '8';
     $sec->section_order_id = '4';
     $sec->sectionName = 'VOUCHER';
     $sec->workflow_id = '2';
     $sec->save();
     // WORKFLOW 3
     $sec = new Section();
     $sec->id = '9';
     $sec->section_order_id = '1';
     $sec->sectionName = 'PURCHASE REQUEST';
     $sec->workflow_id = '3';
     $sec->save();
     $sec = new Section();
     $sec->id = '10';
     $sec->section_order_id = '2';
     $sec->sectionName = 'BAC REQUIREMENTS';
     $sec->workflow_id = '3';
     $sec->save();
     $sec = new Section();
     $sec->id = '11';
     $sec->section_order_id = '3';
     $sec->sectionName = 'PURCHASE ORDER';
     $sec->workflow_id = '3';
     $sec->save();
     $sec = new Section();
     $sec->id = '12';
     $sec->section_order_id = '4';
     $sec->sectionName = 'VOUCHER';
     $sec->workflow_id = '3';
     $sec->save();
     // WORKFLOW 4
     $sec = new Section();
     $sec->id = '13';
     $sec->section_order_id = '1';
     $sec->sectionName = 'PURCHASE REQUEST';
     $sec->workflow_id = '4';
     $sec->save();
     $sec = new Section();
     $sec->id = '14';
     $sec->section_order_id = '2';
     $sec->sectionName = 'REQUIREMENTS';
     $sec->workflow_id = '4';
     $sec->save();
     $sec = new Section();
     $sec->id = '15';
     $sec->section_order_id = '3';
     $sec->sectionName = 'VOUCHER';
     $sec->workflow_id = '4';
     $sec->save();
     // WORKFLOW 5
     $sectionID = 16;
     $sec = new Section();
     $sec->id = $sectionID++;
     $sec->section_order_id = '1';
     $sec->sectionName = 'PURCHASE REQUEST';
     $sec->workflow_id = '5';
     $sec->save();
     $sec = new Section();
     $sec->id = $sectionID++;
     $sec->section_order_id = '2';
     $sec->sectionName = 'REQUIREMENTS';
     $sec->workflow_id = '5';
     $sec->save();
     $sec = new Section();
     $sec->id = $sectionID++;
     $sec->section_order_id = '3';
     $sec->sectionName = 'PURCHASE ORDER';
     $sec->workflow_id = '5';
     $sec->save();
     $sec = new Section();
     $sec->id = $sectionID++;
     $sec->section_order_id = '4';
     $sec->sectionName = 'VOUCHER';
     $sec->workflow_id = '5';
     $sec->save();
 }
 public function __viewIndex()
 {
     $section = Section::load(sprintf('%s/%s.xml', SECTIONS, $this->_context['section_handle']));
     $this->setTitle(__('%1$s &ndash; %2$s', array(__('Symphony'), $section->name)));
     $this->Form->setAttribute("class", $section->handle);
     $filter = $filter_value = $where = $joins = NULL;
     $current_page = isset($_REQUEST['pg']) && is_numeric($_REQUEST['pg']) ? max(1, intval($_REQUEST['pg'])) : 1;
     $current_filter = $filter ? "&filter={$field_handle}:{$filter_value}" : '';
     if (isset($_REQUEST['sort']) && is_string($_REQUEST['sort'])) {
         $sort = $_REQUEST['sort'];
         $order = $_REQUEST['order'] ? strtolower($_REQUEST['order']) : 'asc';
         if ($section->{'publish-order-handle'} != $sort || $section->{'publish-order-direction'} != $order) {
             $section->{'publish-order-handle'} = $sort;
             $section->{'publish-order-direction'} = $order;
             $errors = new MessageStack();
             Section::save($section, $errors);
             redirect(Administration::instance()->getCurrentPageURL() . $current_filter);
         }
     } elseif (isset($_REQUEST['unsort'])) {
         $section->{'publish-order-handle'} = null;
         $section->{'publish-order-direction'} = null;
         $errors = new MessageStack();
         Section::save($section, $errors);
         redirect(Administration::instance()->getCurrentPageURL());
     }
     $this->appendSubheading($section->name, Widget::Anchor(__('Create New'), sprintf('%s/new/%s', Administration::instance()->getCurrentPageURL(), $filter ? "?prepopulate[{$filter}]={$filter_value}" : NULL), array('title' => __('Create a new entry'), 'class' => 'create button')));
     $aTableHead = array();
     $renderOnlyEntryIDColumn = false;
     foreach ($section->fields as $column) {
         if ($column->{'show-column'} != 'yes') {
             continue;
         }
         $label = $column->name;
         if ($column->isSortable()) {
             $link = Administration::instance()->getCurrentPageURL();
             if ($column->{'element-name'} == $section->{'publish-order-handle'}) {
                 $link .= '?pg=' . $current_page . '&sort=' . $column->{'element-name'};
                 $link .= '&order=' . ($section->{'publish-order-direction'} == 'desc' ? 'asc' : 'desc') . $current_filter;
                 $anchor = Widget::Anchor($label, $link, array('title' => __('Sort by %1$s %2$s', array($section->{'publish-order-direction'} == 'desc' ? __('ascending') : __('descending'), strtolower($label))), 'class' => 'active'));
             } else {
                 $link .= '?pg=' . $current_page . '&sort=' . $column->{'element-name'} . '&order=asc' . $current_filter;
                 $anchor = Widget::Anchor($label, $link, array('title' => __('Sort by %1$s %2$s', array(__('ascending'), strtolower($label)))));
             }
             $aTableHead[] = array($anchor, 'col');
         } else {
             $aTableHead[] = array($label, 'col');
         }
     }
     if (count($aTableHead) <= 0) {
         $renderOnlyEntryIDColumn = true;
         $aTableHead[] = array('ID', 'col');
     }
     /*
      **	Pagination, get the total number of entries and work out
      **	how many pages exist using the Symphony config
      **	TODO: Work with Ordering
      */
     try {
         $entry_count = Symphony::Database()->query("SELECT COUNT(id) as `count` FROM `tbl_entries` WHERE `section` = '%s'", array($section->handle))->current()->count;
         $pagination = array('total-entries' => $entry_count, 'entries-per-page' => Symphony::Configuration()->core()->symphony->{'pagination-maximum-rows'}, 'total-pages' => ceil($entry_count / Symphony::Configuration()->core()->symphony->{'pagination-maximum-rows'}), 'current-page' => $current_page);
         $pagination['start'] = $current_page != 1 ? ($current_page - 1) * $pagination['entries-per-page'] : 0;
         $pagination['remaining-entries'] = max(0, $entry_count - ($pagination['start'] + $pagination['entries-per-page']));
     } catch (DatabaseException $ex) {
     }
     //	If there's no sorting, just order by ID, otherwise applying column sorting
     if (!isset($section->{'publish-order-handle'}) || strlen($section->{'publish-order-handle'}) == 0) {
         $entries = Symphony::Database()->query("SELECT * FROM `tbl_entries` WHERE `section` = '%s' ORDER BY `id` ASC LIMIT %d, %d ", array($section->handle, $pagination['start'], $pagination['entries-per-page']), 'EntryResult');
     } else {
         $join = NULL;
         $sort_field = $section->fetchFieldByHandle($section->{'publish-order-handle'});
         $sort_field->buildSortingQuery($join, $order);
         $joins .= sprintf($join, $sort_field->section, $sort_field->{'element-name'});
         $order = sprintf($order, $section->{'publish-order-direction'});
         // TODO: Implement filtering
         $query = sprintf("\n\t\t\t\t\tSELECT e.*\n\t\t\t\t\tFROM `tbl_entries` AS e\n\t\t\t\t\t%s\n\t\t\t\t\tWHERE e.section = '%s'\n\t\t\t\t\tORDER BY %s\n\t\t\t\t\tLIMIT %d, %d", $joins, $section->handle, $order, $pagination['start'], $pagination['entries-per-page']);
         $entries = Symphony::Database()->query($query, array($section->handle, $section->{'publish-order-handle'}), 'EntryResult');
     }
     ## Table Body
     $aTableBody = array();
     $colspan = count($aTableHead);
     if ($entries->length() <= 0) {
         $aTableBody[] = Widget::TableRow(array(Widget::TableData(__('None found.'), array('class' => 'inactive', 'colspan' => $colspan))), array('class' => 'odd'));
     } else {
         foreach ($entries as $entry) {
             $cells = array();
             $link = Widget::Anchor('None', Administration::instance()->getCurrentPageURL() . "/edit/{$entry->id}/", array('id' => $entry->id, 'class' => 'content'));
             $first = true;
             if ($renderOnlyEntryIDColumn != true) {
                 foreach ($section->fields as $column) {
                     if ($column->{'show-column'} != 'yes') {
                         continue;
                     }
                     $field_handle = $column->{'element-name'};
                     if (!isset($entry->data()->{$field_handle})) {
                         $cells[] = Widget::TableData(__('None'), array('class' => 'inactive'));
                     } else {
                         $value = $column->prepareTableValue($entry->data()->{$field_handle}, $first == true ? $link : NULL);
                         $cells[] = Widget::TableData($value, $value == __('None') ? array('class' => 'inactive') : array());
                     }
                     $first = false;
                 }
             } else {
                 $link->setValue($entry->id);
                 $cells[] = Widget::TableData($link);
             }
             $cells[count($cells) - 1]->appendChild(Widget::Input('items[' . $entry->id . ']', NULL, 'checkbox'));
             if (!empty($cells)) {
                 $aTableBody[] = Widget::TableRow($cells);
             }
         }
     }
     $table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody));
     $this->Form->appendChild($table);
     $tableActions = $this->createElement('div');
     $tableActions->setAttribute('class', 'actions');
     $options = array(array(NULL, false, __('With Selected...')), array('delete', false, __('Delete')));
     $index = 2;
     foreach ($section->fields as $field) {
         if ($field->canToggleData() != true) {
             continue;
         }
         $options[$index] = array('label' => __('Set %s', array($field->label)), 'options' => array());
         foreach ($field->getToggleStates() as $value => $state) {
             $options[$index]['options'][] = array('toggle::' . $field->{'element-name'} . '::' . $value, false, $state);
         }
         $index++;
     }
     $tableActions->appendChild(Widget::Select('with-selected', $options));
     $tableActions->appendChild(Widget::Input('action[apply]', __('Apply'), 'submit'));
     $this->Form->appendChild($tableActions);
     if ($pagination['total-pages'] > 1) {
         $current_url = Administration::instance()->getCurrentPageURL() . '/?pg=';
         $ul = $this->createElement('ul');
         $ul->setAttribute('class', 'page');
         ## First
         $li = $this->createElement('li');
         if ($current_page > 1) {
             $li->appendChild(Widget::Anchor(__('First'), $current_url . '1'));
         } else {
             $li->setValue(__('First'));
         }
         $ul->appendChild($li);
         ## Previous
         $li = $this->createElement('li');
         if ($current_page > 1) {
             $li->appendChild(Widget::Anchor(__('&larr; Previous'), $current_url . ($current_page - 1)));
         } else {
             $li->setValue(__('&larr; Previous'));
         }
         $ul->appendChild($li);
         ## Summary
         $li = $this->createElement('li', __('Page %1$s of %2$s', array($current_page, max($current_page, $pagination['total-pages']))));
         $li->setAttribute('title', __('Viewing %1$s - %2$s of %3$s entries', array($pagination['start'] + 1, $current_page != $pagination['total-pages'] ? $current_page * $pagination['entries-per-page'] : $pagination['total-entries'], $pagination['total-entries'])));
         $ul->appendChild($li);
         ## Next
         $li = $this->createElement('li');
         if ($current_page < $pagination['total-pages']) {
             $li->appendChild(Widget::Anchor(__('Next &rarr;'), $current_url . ($current_page + 1)));
         } else {
             $li->setValue(__('Next &rarr;'));
         }
         $ul->appendChild($li);
         ## Last
         $li = $this->createElement('li');
         if ($current_page < $pagination['total-pages']) {
             $li->appendChild(Widget::Anchor(__('Last'), $current_url . $pagination['total-pages']));
         } else {
             $li->setValue(__('Last'));
         }
         $ul->appendChild($li);
         $this->Form->appendChild($ul);
     }
 }
Example #21
0
 public function postSection()
 {
     $cre = ['section_name' => Input::get('section_name')];
     $rules = ['section_name' => 'required'];
     $validator = Validator::make($cre, $rules);
     if ($validator->passes()) {
         $section = new Section();
         $section->cv_id = Input::get('cv_id');
         $section->section_name = Input::get('section_name');
         $section->type = 0;
         $section->priority = DB::table('sections')->where('cv_id', Input::get('cv_id'))->max('priority') + 1;
         $section->save();
         $insert_id = $section->id;
         $data["message"] = 'Section is succefully added';
         $data["section_name"] = Input::get('section_name');
         $data["id"] = $insert_id;
         return json_encode($data);
     } else {
         return 'Please fill all the inputs';
     }
 }