/** * Event Function used while updating a company * Checks if the updated Company is already in the database * If there then do not update and set doSave = mo * Else continue with other events from the called page * */ function eventCheckDuplicateCompanyInUpdate(EventControler $evtcl) { $fields = $evtcl->getParam('fields'); $q_company = new sqlQuery($this->getDbCon()); $q_company->query("select name from company where idcompany = " . $this->getPrimaryKeyValue()); $q_company->fetch(); $comp_name = $q_company->getData("name"); $q = new sqlQuery($this->getDbCon()); $q->query("select * from company where name='" . trim($fields['name']) . "' \r\n AND name <> '" . trim($comp_name) . "'"); // need to have the iduser as well if ($q->getNumRows() > 0) { $dispError = new Display($evtcl->goto); $dispError->addParam("message", "This company is already in the database"); $evtcl->addParam("doSave", "no"); $evtcl->setDisplayNext($dispError); } }
<?php /** Ofuz Open Source version is released under the GNU Affero General Public License, please read the full license at: http://www.gnu.org/licenses/agpl-3.0.html **/ // Copyright 2008 - 2010 all rights reserved, SQLFusion LLC, info@sqlfusion.com /** Ofuz Open Source version is released under the GNU Affero General Public License, please read the full license at: http://www.gnu.org/licenses/agpl-3.0.html **/ include_once 'config.php'; include_once 'includes/ofuz_check_access.script.inc.php'; //include_once('includes/header.inc.php'); //the browser_search.php will instantiate an EventControler object, set the search param, goto and pass it to the $_SESSION['do_contact']->eventSetSearch($eventcontroler); $do_Contacts = new Contact(); $do_Contacts->sessionPersistent("do_Contacts", "index.php", 36000); $ec_search = new EventControler($conx); $ec_search->addParam("goto", "contacts.php"); $ec_search->addParam("contacts_search", $_GET['s']); $_SESSION['do_Contacts']->search_keyword = $_GET['s']; $_SESSION['do_Contacts']->eventSetSearch($ec_search); $ec_search->doForward();
function eventCancelExtraAmtPay(EventControler $evtcl) { $_SESSION['extra_amt'] = ''; $_SESSION['ref_num'] = ''; $_SESSION['last_paylogid'] = ''; $evtcl->addParam("goto", "invoices.php"); $_SESSION['do_invoice_list']->eventUnsetFilterInvoice($evtcl); }
* @version 1.3 */ //session_start(); require_once 'config.php'; require_once 'Zend/OpenId/Consumer.php'; $eventControler = new EventControler($GLOBALS['conx']); $eventControler->setLogRun(true); $eventControler->setMyDbPath($cfg_local_mydbdir); $eventControler->setMessagePage("message.php"); $eventControler->setCheckReferer(false); //echo $_SESSION['openid_userclass']; if (!isset($_SESSION['openid_userclass'])) { $eventControler->setUrlNext("index.php"); $eventControler->doForward(); exit; } else { $cur_userclass = $_SESSION['openid_userclass']; } $eventControler->setLog("\n--- OpenId Call back --"); $eventControler->setLog("\n userclass:" . $_SESSION['openid_userclass']); $eventControler->setLog("\n openid_mode:" . $_GET['openid_mode']); $events = array(); $events[50] = $cur_userclass . "->eventCheckOpenIdCallBack"; $events[40] = "mydb.gotoPage"; if (isset($_GET['openid_mode'])) { $eventControler->addParam("goto", "sess_test2.php"); $eventControler->listenEvents($events); $eventControler->doForward(); //echo $eventControler->getUrlNext(); } //unset($_SESSION['openid_userclass']);
function eventLoadParams(EventControler $event_controler) { $disperr = new Display($this->getMessagePage()); $mydb_paramkeys = $_SESSION["mydb_paramkeys"]; $mydb_eventkey = $event_controler->mydb_eventkey; $this->setLog("\n Event Key: " . $mydb_eventkey); if (isset($GLOBALS['cfg_event_param_garbage_time_out'])) { $cfg_event_param_garbage_time_out = $GLOBALS['cfg_event_param_garbage_time_out']; } else { $cfg_event_param_garbage_time_out = 600; } if (isset($GLOBALS['cfg_event_param_garbage_interval'])) { $cfg_event_param_garbage_interval = $GLOBALS['cfg_event_param_garbage_interval']; } else { $cfg_event_param_garbage_interval = 120; } if (!isset($_SESSION['pas_event_garbage_timeout'])) { $_SESSION['pas_event_garbage_timeout'] = time(); } $this->setLog("\n current Time is :" . date("H:i:s", time())); $this->setLog("\n timeout set to: " . date("H:i:s", $_SESSION['pas_event_garbage_timeout'])); if (is_array($mydb_paramkeys) && !empty($mydb_eventkey)) { if (is_array($mydb_paramkeys[$mydb_eventkey])) { foreach ($mydb_paramkeys[$mydb_eventkey] as $varname => $varvalue) { $GLOBALS[$varname] = $varvalue; $event_controler->addParam($varname, $varvalue); $this->setLog("\n Restoring vars :" . $varname . "=" . $varvalue); } } // $this->setLog("\n event referer:".$GLOBALS['pas_event_referer']); unset($_SESSION['mydb_paramkeys'][$mydb_eventkey]); //session_register("mydb_paramkeys") ; $this->setLog("\n\n-" . $_SESSION['pas_event_garbage_timeout'] + $cfg_event_param_garbage_interval . " < " . time()); if ($_SESSION['pas_event_garbage_timeout'] + $cfg_event_param_garbage_interval < time()) { $old_paramkeys = $_SESSION['mydb_paramkeys']; $this->setLog("\n Running events param garbage collector"); foreach ($old_paramkeys as $key => $a_params) { if ($a_params['pas_event_timestamp'] + $cfg_event_param_garbage_time_out > time()) { $new_paramkeys[$key] = $a_params; $this->setLog("\n Keep event:" . $key . " at:" . date("Y/m/d - H:i:s", $a_params['pas_event_timestamp'])); } } $_SESSION['mydb_paramkeys'] = $new_paramkeys; $_SESSION['pas_event_garbage_timeout'] = time(); } } else { $disperr->addParam("message", "This event requires mydb_paramkeys from the session and mydb_eventkey as parameter"); $event_controler->setDisplayNext($disperr); } $this->setLogRun($logrun); }
<?php /** * Webform eventcontoler scipt will get post content form webform html section and process to the database. * @param POST data * Created on Dec 30 2011 * */ include_once "config.php"; $fields = array(); $efid = $_POST['fid']; $euid = $_POST['uid']; $tags = $_POST['tags']; $do_user_rel = new UserRelations(); $fid = $do_user_rel->decrypt($efid); $uid = $do_user_rel->decrypt($euid); //$do_userform = new WebFormUser(); //$do_userform->posteventAddContact($fid,$_POST['fields'],$nxturl,$uid,$tags); $evctl = new EventControler(); $evctl->addParam('fields', $_POST['fields']); $evctl->addParam('uid', $uid); $evctl->addParam('fid', $fid); $do_userform = new WebFormUser(); $do_userform->eventAddContact($evctl);
/** * saveWebForm() * this will check if contact exists with firname, lastname, name and email * If exist add to it, if doesn't exists create a new one. */ function eventAddContact(EventControler $event_controler) { //$fields = $_REQUEST['fields']; $fields = $event_controler->fields; $this->setLog("\n eventAddContact, creating new contact from form, using " . count($fields) . " fields. (" . date("Y/m/d H:i:s") . ")"); //$dropcode = $_POST['dropcode']; if (isset($this->iduser)) { $do_contact = new Contact(); $do_contact->iduser = $this->iduser; $do_contact->add(); $this->setLog("\n new contact:" . $do_contact->idcontact . " for user:"******"\n new contact:" . $do_contact->idcontact . " for user:"******"\n Processing field:" . $field_name . " with value:" . $field_value); if (isset($this->idwebformuser)) { $do_webform_fields = new WebFormUserField(); $do_webform_fields->query("SELECT wfu.name, wff.class as class_name, wff.variable, wff.variable_type, wfu.required \n\t\t FROM webformfields as wff, webformuserfield as wfu \n WHERE wff.name=wfu.name\n AND wfu.name = '" . $field_name . "'\n AND wfu.idwebformuser= "******"SELECT wfu.name, wff.class as class_name, wff.variable, wff.variable_type, wfu.required \n FROM webformfields as wff, webformuserfield as wfu \n WHERE wff.name=wfu.name\n AND wfu.name = '" . $field_name . "'\n AND wfu.idwebformuser= "******"\n Field information class:" . $do_webform_fields->class_name . " Variable:" . $do_webform_fields->variable); $this->setLog("\n rows:" . $do_webform_fields->getNumRows()); if ($do_webform_fields->getNumRows() == 1) { if ($do_webform_fields->class_name == "Contact") { $this->setLog("\n Updating contact"); $do_contact->{$do_webform_fields->variable} = $field_value; $do_contact->update(); } else { $update = false; if (is_object(${'sub_' . $do_webform_fields->class_name})) { if (${'sub_' . $do_webform_fields->class_name}->getType() == $do_webform_fields->variable_type) { $update = true; } } if ($update) { $this->setLog("\n Updating class:" . $do_webform_fields->class_name); $obj = ${'sub_' . $do_webform_fields->class_name}; $obj->{$do_webform_fields->variable} = $field_value; $obj->update(); } else { $class_name = $do_webform_fields->class_name; ${'sub_' . $class_name} = new $class_name(); $obj = ${'sub_' . $class_name}; $obj->{$do_webform_fields->variable} = $field_value; if (method_exists($obj, "setType") && strlen($do_webform_fields->variable_type) > 0) { $obj->setType($do_webform_fields->variable_type); } $obj->idcontact = $do_contact->getPrimaryKeyValue(); $obj->iduser = $event_controler->uid; $obj->add(); } } } } if (isset($this->iduser)) { $contact_view = new ContactView(); $contact_view->setUser($this->iduser); $contact_view->addFromContact($do_contact); } else { $contact_view = new ContactView(); $contact_view->setUser($event_controler->uid); $contact_view->addFromContact($do_contact); } if (isset($this->tags)) { $tags = explode(",", $this->tags); foreach ($tags as $tag) { $tag = trim($tag); $do_tag = new Tag(); $do_tag->addNew(); $do_tag->addTagAssociation($do_contact->getPrimaryKeyValue(), $tag, "contact", $this->iduser); $contact_view->addTag($tag); } if (strlen($this->urlnext) > 0) { $event_controler->setUrlNext($this->urlnext); } else { $event_controler->setUrlNext($GLOBALS['cfg_ofuz_site_http_base'] . 'web_form_thankyou.php'); } $event_controler->addParam("do_contact", $do_contact); } else { $sql = "SELECT * FROM {$this->table} WHERE idwebformuser={$event_controler->fid}"; $this->query($sql); while ($this->fetch()) { $tags = $this->getData("tags"); $urlnext = $this->getData("urlnext"); } $tags = explode(",", $tags); foreach ($tags as $tag) { $tag = trim($tag); $do_tag = new Tag(); $do_tag->addNew(); $do_tag->addTagAssociation($do_contact->getPrimaryKeyValue(), $tag, "contact", $this->iduser); $contact_view->addTag($tag); } if (strlen($urlnext) > 0) { $event_controler->setUrlNext($urlnext); } else { $url = $GLOBALS['cfg_ofuz_site_http_base'] . 'web_form_thankyou.php'; //$event_controler->setUrlNext($url); //header("location:$url"); $err_disp = new Display($url); $event_controler->setDisplayNext($err_disp); $event_controler->doForward(); } //$event_controler->addParam("do_contact", $do_contact); } }
/** * Receives progress bar % value and writes to the DB */ function eventAjaxUpdateProgress(EventControler $event_controler) { $q = new sqlQuery($this->getDbCon()); $q->query("UPDATE project_task SET progress = '{$event_controler->progress}' WHERE idproject_task = {$event_controler->idproject_task}"); $WorkFeedProjectTask = new WorkFeedProjectTask(); $evctl = new EventControler(); $evctl->addParam('task_event_type', 'task_progress'); $evctl->addParam('progress', $event_controler->progress); $WorkFeedProjectTask->eventAddFeed($evctl); $event_controler->addOutputValue(true); }