本文整理汇总了PHP中I2CE_FormStorage::search方法的典型用法代码示例。如果您正苦于以下问题:PHP I2CE_FormStorage::search方法的具体用法?PHP I2CE_FormStorage::search怎么用?PHP I2CE_FormStorage::search使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类I2CE_FormStorage
的用法示例。
在下文中一共展示了I2CE_FormStorage::search方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate_form_reschedule_course
public function validate_form_reschedule_course($form)
{
$semester = implode("|", $form->new_semester);
$course = implode("|", $form->training);
$academic_year = implode("|", $form->academic_year);
$username = $this->getUser()->username;
$training_institution = iHRIS_PageFormLecturer::fetch_institution($username);
$where = array("operator" => "AND", "operand" => array(0 => array("operator" => "FIELD_LIMIT", "field" => "academic_year", "style" => "equals", "data" => array("value" => $academic_year)), 1 => array("operator" => "FIELD_LIMIT", "field" => "training", "style" => "equals", "data" => array("value" => $course)), 2 => array("operator" => "FIELD_LIMIT", "field" => "training_institution", "style" => "equals", "data" => array("value" => $training_institution))));
$is_rescheduled = I2CE_FormStorage::search("reschedule_course", false, $where);
if (count($is_rescheduled) > 0) {
$form->setInvalidMessage("training", "This Course Already Rescheduled For This Semester In This Academic Year");
}
$ff = I2CE_FormFactory::instance();
if (!($courseObj = $ff->createContainer($course)) instanceof iHRIS_Training) {
return;
}
$courseObj->populate();
$crs_semester = $courseObj->getField("semester")->getDBValue();
if ($crs_semester == $semester) {
$form->setInvalidMessage("new_semester", "This Course Is Currently Offered In This Semester");
return;
}
$sem = $form->new_semester[1];
$crs_semester = explode("|", $crs_semester);
$crs_semester = $crs_semester[1];
if ($crs_semester > $sem or $sem - $crs_semester != 1) {
$form->setInvalidMessage("new_semester", "A Course Must Be Rescheduled To A Next Semester");
}
}
示例2: action
/**
* Perform the actions of this page.
* @return boolean
*/
protected function action()
{
if (parent::action()) {
$next_month = getdate(mktime(0, 0, 0, $this->month + 1, 1, $this->year));
$db_start = sprintf('%04d-%02d-%02d', $this->year, $this->month, 1);
$db_end = sprintf('%04d-%02d-%02d', $next_month['year'], $next_month['mon'], $next_month['mday']);
$find_instances = array('operator' => 'OR', 'operand' => array(0 => array('operator' => 'AND', 'operand' => array(0 => array('operator' => 'FIELD_LIMIT', 'style' => 'greaterthan_equals', 'field' => 'start_date', 'data' => array('value' => $db_start)), 1 => array('operator' => 'FIELD_LIMIT', 'style' => 'lessthan', 'field' => 'start_date', 'data' => array('value' => $db_end)))), 1 => array('operator' => 'AND', 'operand' => array(0 => array('operator' => 'FIELD_LIMIT', 'style' => 'greaterthan_equals', 'field' => 'end_date', 'data' => array('value' => $db_start)), 1 => array('operator' => 'FIELD_LIMIT', 'style' => 'lessthan', 'field' => 'end_date', 'data' => array('value' => $db_end))))));
$instances = I2CE_FormStorage::search("scheduled_training_course", false, $find_instances);
$factory = I2CE_FormFactory::instance();
$month_end = new DateTime($db_end);
$deviation = 35;
$base = array(70, 116, 149);
foreach ($instances as $instance) {
$rgb = array();
foreach ($base as $idx => $num) {
$rgb[$idx] = rand($num - $deviation, $num + $deviation);
}
$inst = $factory->createContainer("scheduled_training_course|{$instance}");
$inst->populate();
$this->addForm($inst, $inst->start_date->getDateTimeObj(), $inst->end_date->getDateTimeObj(), 'calendar_training_course_day.html', $rgb);
}
} else {
return false;
}
return true;
}
示例3: save
/**
* Check for duplicates and save the user alert
* @param I2CE_User $user
* @param boolean $transact
* @return boolean
*/
public function save($user, $transact = true)
{
if ($this->getId() === '0') {
$find_duplicates = array('operator' => 'AND', 'operand' => array(array('operator' => 'FIELD_LIMIT', 'field' => 'message', 'style' => 'lowerequals', 'data' => array('value' => strtolower($this->message))), array('operator' => 'FIELD_LIMIT', 'field' => 'time_ack', 'style' => 'null'), array('operator' => 'FIELD_LIMIT', 'field' => 'alert_type', 'style' => 'equals', 'data' => array('value' => $this->alert_type))));
if ($this->link == '') {
$find_duplicates['operand'][] = array('operator' => 'FIELD_LIMIT', 'field' => 'link', 'style' => 'null');
} else {
$find_duplicates['operand'][] = array('operator' => 'FIELD_LIMIT', 'field' => 'link', 'style' => 'equals', 'data' => array('value' => $this->link));
}
if ($this->link_text == '') {
$find_duplicates['operand'][] = array('operator' => 'FIELD_LIMIT', 'field' => 'link_text', 'style' => 'null');
} else {
$find_duplicates['operand'][] = array('operator' => 'FIELD_LIMIT', 'field' => 'link_text', 'style' => 'lowerequals', 'data' => array('value' => strtolower($this->link_text)));
}
$found = I2CE_FormStorage::search('user_alert', $this->getParent(), $find_duplicates, array("-time_sent"), 1);
if ($found) {
I2CE::raiseMessage("found duplicates so increasing repeats. {$found}");
$duplicate = I2CE_FormFactory::instance()->createContainer("user_alert|" . $found);
$duplicate->populate();
$duplicate->repeated++;
return $duplicate->save($user, $transact);
}
}
return parent::save($user, $transact);
}
示例4: loadObjects
protected function loadObjects()
{
if (!$this->hasPermission("task(can_schedule_students_course_enrollment)") or $this->getUser()->role == "admin") {
$this->setRedirect("noaccess");
}
$factory = I2CE_FormFactory::instance();
$username = $this->getUser()->username;
$training_institution = IHS_PageFormLecturer::fetch_institution($username);
$where = array("operator" => "FIELD_LIMIT", "field" => "training_institution", "style" => "equals", "data" => array("value" => $training_institution));
$fields = I2CE_FormStorage::search("schedule_course_enrollment", false, $where);
foreach ($fields as $id) {
//do nothing
}
if ($id) {
$form = "schedule_course_enrollment|" . $id;
} else {
$form = "schedule_course_enrollment";
}
$courseEnrObj = $factory->createContainer($form);
$courseEnrObj->populate();
if ($this->isPost()) {
$courseEnrObj->load($this->post);
}
$courseEnrObj->getField("training_institution")->setFromDB($training_institution);
$this->setObject($courseEnrObj);
}
示例5: getArchiveIds
public static function getArchiveIds($reportView, $date = null)
{
$where = array('operator' => 'FIELD_LIMIT', 'field' => 'report_view', 'style' => 'equals', 'data' => array('value' => $reportView));
if ($date) {
$where = array('operator' => 'AND', 'operand' => array($where, array('operator' => 'FIELD_LIMIT', 'field' => 'date', 'style' => 'equals', 'data' => array('value' => $date))));
}
return I2CE_FormStorage::search('archived_report', false, $where);
}
示例6: generate
public function generate($node)
{
if (!$node instanceof DOMNode || !$this->primaryObject instanceof I2CE_Form || I2CE_PermissionParser::taskExists($this->options['task']) && !$this->page->hasPermission("task(" . $this->options['task'] . ")", $node) || !($linkedNode = $this->template->appendFileByNode($this->options['template'], 'div', $node)) instanceof DOMNode || !($tbodyNode = $this->template->getElementByName('child_fields', 0, $node)) instanceof DOMNode) {
return false;
}
$added = 0;
if (count($this->options['action_links']) > 0 && ($ulNode = $this->template->getElementByName('child_links', 0, $linkedNode)) instanceof DOMNode) {
$added = $this->addLinks('li', $this->options['action_links'], $ulNode);
}
if ($added == 0 && ($containerNode = $this->template->getElementByName('child_actions', 0, $linkedNode)) instanceof DOMNode) {
$this->template->removeNode($containerNode);
}
$this->template->setDisplayDataImmediate('child_title', $this->options['title'], $linkedNode);
$dispDatas = array();
$arg_walker = array();
if ($this->options['printf'] && is_array($this->options['printf_args'])) {
foreach ($this->options['printf_args'] as $i => &$arg) {
$t_arg = explode(":", $arg);
if (count($t_arg) > 1) {
$arg_walker[$i] = $t_arg;
$arg = $t_arg[0];
}
}
unset($arg);
$dispDatas = I2CE_FormStorage::listDisplayFields($this->options['form'], $this->options['printf_args'], $this->primaryObject->getNameId(), $this->options['where'], $this->options['orders'], $this->options['limit']);
$ids = array_keys($dispDatas);
} else {
$ids = I2CE_FormStorage::search($this->options['form'], $this->primaryObject->getNameId(), $this->options['where'], $this->options['orders'], $this->options['limit']);
}
if (count($ids) == 0) {
return false;
}
foreach ($ids as $id) {
$text = $this->options['title'];
//default text for child in case printf wasn't set.
if (array_key_exists($id, $dispDatas) && is_array($dispDatas)) {
$dispFields = $dispDatas[$id];
foreach ($this->options['printf_args'] as $i => $arg) {
$dispData[$i] = $dispFields[$arg];
}
foreach ($arg_walker as $i => $fields) {
$val = $dispData[$i];
$count = 0;
foreach ($fields as $field) {
$count++;
if ($count == 1) {
continue;
}
list($wform, $wid) = array_pad(explode('|', $val, 2), 2, '');
$val = I2CE_FormStorage::lookupField($wform, $wid, array($field), '');
}
$dispData[$i] = $val;
}
$text = @vsprintf($this->options['printf'], $dispData);
}
$this->generateAjaxLink($id, $text, $tbodyNode);
}
}
示例7: loadObjects
/**
* Create and load data for the objects used for this form.
*/
protected function loadObjects()
{
$this->ff = I2CE_FormFactory::instance();
//check to ensure that the current academic year is available
iHRIS_AcademicYear::ensureAcademicYear();
$selected_courses = $this->post("course");
$person_id = $this->post("person_id");
$curr_semester = $this->post("curr_semester");
$student_registration = STS_PageFormPerson::load_current_registration($person_id);
if (count($selected_courses) == 0) {
$this->userMessage("No courses Selected!!!");
$this->setRedirect("view?id=" . $this->person_id);
}
foreach ($selected_courses as $course) {
$courseObj = $this->factory->createContainer($course);
$courseObj->populate();
$total_credits = $total_credits + $courseObj->getField("course_credits")->getDBValue();
}
$selected_courses = implode(",", $selected_courses);
$where = array("operator" => "AND", "operand" => array(0 => array("operator" => "FIELD_LIMIT", "field" => "parent", "style" => "equals", "data" => array("value" => $person_id)), 1 => array("operator" => "FIELD_LIMIT", "field" => "semester", "style" => "equals", "data" => array("value" => $curr_semester)), 2 => array("operator" => "FIELD_LIMIT", "field" => "registration", "style" => "equals", "data" => array("value" => $student_registration["id"]))));
$enrolled_courses = I2CE_FormStorage::search("enroll_course", false, $where);
if (count($enrolled_courses) > 0) {
foreach ($enrolled_courses as $enrollment) {
$course_enrollment_form = "enroll_course|" . $enrollment;
}
} else {
$course_enrollment_form = "enroll_course";
}
if (!($enrollcourseObj = $this->ff->createContainer($course_enrollment_form)) instanceof I2CE_Form) {
I2CE::raiseError("Invalid Object");
return false;
}
$trainingCourseField = $enrollcourseObj->getField("training");
$trainingCourseField->setFromPost($selected_courses);
$date_enrolled = date("Y-m-d");
$enrollcourseObj->getField("date_enrolled")->setFromDB($date_enrolled);
$semesterField = $enrollcourseObj->getField("semester");
$semesterField->setFromPost($curr_semester);
$enrollcourseObj->getField("total_credits")->setValue($total_credits);
$enrollcourseObj->getField("registration")->setFromDB($student_registration["id"]);
$current_academic_year = iHRIS_AcademicYear::currentAcademicYear();
$academic_year_id = iHRIS_AcademicYear::academicYearId($current_academic_year);
$academic_year_id = "academic_year|" . $academic_year_id;
if (!($academicYearField = $enrollcourseObj->getField("academic_year")) instanceof I2CE_FormField_MAP) {
return;
}
$academicYearField->setFromDB($academic_year_id);
$parentObj = $this->ff->createContainer($person_id);
if ($parentObj instanceof I2CE_Form) {
$parentObj->populate();
}
$this->setObject($enrollcourseObj, I2CE_PageForm::EDIT_PRIMARY);
$this->setObject($parentObj, I2CE_PageForm::EDIT_PARENT);
parent::save();
$this->userMessage("Courses Enrolled Successfully");
$this->setRedirect("view?id=" . $person_id);
return true;
}
示例8: action_drop_semester
public function action_drop_semester($page)
{
if (!$page instanceof iHRIS_PageView) {
return false;
}
$template = $page->getTemplate();
$appendNode = $template->getElementById('drop_semester');
if (!$appendNode instanceof DOMNode) {
return true;
}
$person = $page->getPerson();
if (!$person instanceof iHRIS_Person) {
return false;
}
$factory = I2CE_FormFactory::instance();
$where = array("operator" => "FIELD_LIMIT", "field" => "parent", "style" => "equals", "data" => array("value" => "person|" . $person->getId()));
$dropped_semIds = I2CE_FormStorage::search("drop_semester", false, $where);
$drpsem = array();
foreach ($dropped_semIds as $id) {
$dropSemForm = $factory->createContainer('drop_semester' . '|' . $id);
$dropSemForm->populate();
$drpsem[] = $dropSemForm;
}
if (count($drpsem) == 0) {
return false;
}
foreach ($drpsem as $child) {
$node = $template->appendFileByNode('view_drop_semester.html', 'div', $appendNode);
if (!$node instanceof DOMNode) {
I2CE::raiseError("Could not find template {$template} for child form {$form} of person");
return false;
}
$template->setForm($child, $node);
$child->populateChildren('resume_semester');
$resumes = $child->getChildren('resume_semester');
if (count($resumes) > 0) {
$template->setDisplayDataImmediate('has_exam_results', 1, $node);
foreach ($resumes as $resume) {
if (!($resumeNode = $template->appendFileById('view_resume_semester.html', 'tbody', 'resume_semester', false, $node)) instanceof DOMNode) {
continue;
}
$template->setForm($resume, $resumeNode);
}
} else {
$template->setDisplayDataImmediate('has_resume_semester', 0, $node);
}
$drop_semester = $factory->createContainer($child->drop_semester);
if (!$drop_semester instanceof iHRIS_DropSemester || $drop_semester->getId() == '0') {
I2CE::raiseError("Bad Drop Semester:" . $child->drop_semester);
continue;
}
$drop_semester->populate();
$template->setForm($drop_semester, $node);
}
}
示例9: getSampleIDs
protected function getSampleIDs()
{
if (!($argsChild = $this->getChild('args', false)) instanceof I2CE_Swiss_PageArgs || !($rel_obj = $argsChild->getRelationship()) instanceof I2CE_FormRelationship || !($form = $rel_obj->getForm('primary_form')) || !is_array($ids = I2CE_FormStorage::search($form, false, array(), array(), 5))) {
return array();
}
foreach ($ids as &$id) {
$id = $form . '|' . $id;
}
unset($id);
return $ids;
}
示例10: getMapOptions
/**
*@returns array where keys are ids, values are arrays with the following keys 'value', 'display'
*/
public function getMapOptions($type = 'default', $show_hidden = 0, $flat = true, $add_limits = array())
{
$form = $this->getContainer()->getName();
$ff = I2CE_FormFactory::instance();
$data = array();
foreach (I2CE_FormStorage::search($form) as $id) {
if (!($formObj = $ff->createContainer($form . '|' . $id)) instanceof I2CE_List) {
continue;
}
$formObj->populate();
$data[] = array('display' => $formObj->name() . ' [[' . $id . ']]', 'value' => "{$form}|{$id}");
}
return $data;
}
示例11: populate
/**
* Populate the member variables of the object from the database.
*/
public function populate()
{
parent::populate();
if ($this->trained_outside) {
$this->out_cadre = $this->cadre;
} else {
$this->in_cadre = $this->cadre;
$where_data = array('operator' => 'AND', 'operand' => array(array('operator' => 'FIELD_LIMIT', 'field' => 'training_institution', 'style' => 'equals', 'data' => array('value' => $this->getField("training_institution")->getDBValue())), array('operator' => 'FIELD_LIMIT', 'field' => 'cadre', 'style' => 'equals', 'data' => array('value' => $this->getField("in_cadre")->getDBValue()))));
$training_program = I2CE_FormStorage::search('training_program', false, $where_data);
if (count($training_program) > 0) {
$this->getField("training_program")->setFromDB("training_program|" . $training_program[0]);
}
}
}
示例12: showCourses
protected function showCourses()
{
if (!($listNode = $this->template->getElementByID("existing_course_list")) instanceof DOMNode) {
return;
}
if ($this->getUser()->role == "registrar" || $this->getUser()->role == "lecturer" || $this->getUser()->role == "hod" || $this->getUser()->role == "principal" || $this->getUser()->role == "deputy_principal") {
######getting id of the currently logged in lecturer######
$username = $this->getUser()->username;
$where = array("operator" => "FIELD_LIMIT", "field" => "identification_number", "style" => "equals", "data" => array("value" => $username));
$lecturer = I2CE_FormStorage::search("lecturer", false, $where);
foreach ($lecturer as $id) {
$lecturer_id = "lecturer|" . $id;
}
######Getting the current academic year######
$academic_year = iHRIS_AcademicYear::currentAcademicYear();
$where = array("operator" => "FIELD_LIMIT", "field" => "name", "style" => "equals", "data" => array("value" => $academic_year));
$academic_year_id = I2CE_FormStorage::Search("academic_year", false, $where);
$academic_year_id = "academic_year|" . $academic_year_id[0];
######Getting a list of courses assigned to this lecturer######
$where_assign_course = array("operator" => "AND", "operand" => array(0 => array("operator" => "FIELD_LIMIT", "field" => "lecturer", "style" => "equals", "data" => array("value" => $lecturer_id)), 1 => array("operator" => "FIELD_LIMIT", "field" => "academic_year", "style" => "equals", "data" => array("value" => $academic_year_id))));
$assigned_courses = I2CE_FormStorage::listFields("assign_course_trainer", array("training"), false, $where_assign_course);
} else {
$this->userMessage("Login as a training provider to add results");
$this->redirect("manage?action=provider");
return false;
}
######Displaying courses assigned to this lecturer######
if (count($assigned_courses) == 0) {
$this->userMessage("No courses assigned to you,contact the Registrar for further assistance");
$this->redirect("manage?action=provider");
return false;
}
foreach ($assigned_courses as $id => $course) {
$course_id = explode("|", $course["training"]);
$course_id = $course_id[1];
$where = array("operator" => "FIELD_LIMIT", "field" => "id", "style" => "equals", "data" => array("value" => $course_id));
$training_courses = I2CE_FormStorage::ListFields("training", array("name", "code"), false, $where);
foreach ($training_courses as $id => $training_course) {
$course_name = $training_course["name"];
$course_code = $training_course["code"];
$course = $course_code . "-" . $course_name;
$id = "training|" . $id;
$aNode = $this->template->createElement("a", array(href => "add_results?id=" . $id), $course);
$liNode = $this->template->createElement("li");
$this->template->appendNode($aNode, $liNode);
$this->template->appendNode($liNode, $listNode);
}
}
}
示例13: resaveTrainings
protected function resaveTrainings()
{
$user = new I2CE_User();
$ff = I2CE_FormFactory::instance();
$ids = I2CE_FormStorage::search('person_scheduled_training_course');
foreach ($ids as $id) {
I2CE::longExecution();
//to make sure we don't time out
if (!($pstc = $ff->createContainer(array('person_scheduled_training_course', $id))) instanceof iHRIS_Person_Scheduled_Training_Course) {
return false;
//something is wrong
}
$pstc->populate();
//populate will recacluate the average field
$pstc->save($user);
//saves the new calculated average field to the databse
$pstc->cleanup();
//free up memory
}
return true;
}
示例14: action
/**
* Perform the main actions of the page.
*/
protected function action()
{
parent::action();
$factory = I2CE_FormFactory::instance();
if ($this->type == "health_facility") {
$where_data = array('operator' => 'FIELD_LIMIT', 'field' => 'health_facility', 'style' => 'equals', 'data' => array('value' => $this->list->getNameId()));
$institutions = I2CE_FormStorage::search('facility_institution', false, $where_data);
//$institutions = iHRIS_FacilityInstitution::search( "health_facility", $this->id );
foreach ($institutions as $id) {
$obj = $factory->createContainer("facility_institution|" . $id);
$obj->populate();
if ($obj->active == 1) {
$node = $this->template->appendFileById("view_list_hf_ti.html", "span", "training_institution");
$obj->getField("training_institution")->setHref("view_list?type=training_institution&id=");
$this->template->setForm($obj, $node);
}
}
} elseif ($this->type == "training_institution") {
$where_data = array('operator' => 'FIELD_LIMIT', 'field' => 'training_institution', 'style' => 'equals', 'data' => array('value' => $this->list->getNameId()));
$facilities = I2CE_FormStorage::search('facility_institution', false, $where_data, array("health_facility"));
//$facilities = iHRIS_FacilityInstitution::search( "training_institution", $this->id );
foreach ($facilities as $id) {
$obj = $factory->createContainer("facility_institution|" . $id);
$obj->populate();
if ($obj->active == 1) {
$node = $this->template->appendFileById("view_list_ti_hf.html", "span", "health_facility");
$obj->getField("health_facility")->setHref("view_list?type=health_facility&id=");
$this->template->setForm($obj, $node);
}
}
$where_data = array('operator' => 'FIELD_LIMIT', 'field' => 'training_institution', 'style' => 'equals', 'data' => array('value' => $this->list->getNameId()));
$programs = I2CE_FormStorage::search('training_program', false, $where_data);
foreach ($programs as $id) {
$obj = $factory->createContainer("training_program|" . $id);
$obj->populate();
$node = $this->template->appendFileById("view_list_training_program.html", "div", "training_program");
$this->template->setForm($obj, $node);
}
}
}
示例15: getFormObjByWhere
function getFormObjByWhere($form, $where)
{
global $form_factory;
$formIds = I2CE_FormStorage::search($form, false, $where);
if (count($formIds) > 1) {
//I2CE::raiseError("Ambigous lookup for form $form:" . print_r($where,true));
return null;
//the above should die but who knows.
} else {
if (count($formIds) == 1) {
reset($formIds);
$formObj = $form_factory->createForm($form . '|' . current($formIds));
if (!$formObj instanceof I2CE_Form) {
return null;
}
$formObj->populate();
return $formObj;
} else {
return null;
}
}
}