function upgrade_module_1_3_2_11($object) { $themes = Theme::getThemes(); $theme_meta_value = array(); foreach ($object->controllers as $controller) { $page = 'module-' . $object->name . '-' . $controller; $result = Db::getInstance()->getValue('SELECT * FROM ' . _DB_PREFIX_ . 'meta WHERE page="' . pSQL($page) . '"'); if ((int) $result > 0) { continue; } $meta = new Meta(); $meta->page = $page; $meta->configurable = 0; $meta->save(); if ((int) $meta->id > 0) { foreach ($themes as $theme) { $theme_meta_value[] = array('id_theme' => $theme->id, 'id_meta' => $meta->id, 'left_column' => (int) $theme->default_left_column, 'right_column' => (int) $theme->default_right_column); } } else { $object->_errors[] = sprintf(Tools::displayError('Unable to install controller: %s'), $controller); } } if (count($theme_meta_value) > 0) { return Db::getInstance()->insert('theme_meta', $theme_meta_value); } return true; }
/** * Install Procedure */ public function install() { // Set an url rewriting for prediggo search page $oMeta = new Meta(); $oMeta->page = 'search_prediggo'; $oMeta->title = array(1 => '', 2 => ''); $oMeta->description = array(1 => '', 2 => ''); $oMeta->keywords = array(1 => '', 2 => ''); $oMeta->url_rewrite = array(1 => 'prediggo_search', 2 => 'prediggo_recherche'); // Set the hook registration return $oMeta->save() && Db::getInstance()->autoExecute(_DB_PREFIX_ . 'meta', array('page' => 'modules/prediggo/prediggo_search'), 'UPDATE', '`page` = "search_prediggo"') && Tools::generateHtaccess(dirname(__FILE__) . '/../../.htaccess', Configuration::get('PS_REWRITING_SETTINGS'), Configuration::get('PS_HTACCESS_CACHE_CONTROL'), Configuration::get('PS_HTACCESS_SPECIFIC')) && parent::install() && $this->oPrediggoConfig->install() && $this->oPrediggoExportConfig->install() && $this->oPrediggoRecommendationConfig->install() && $this->oPrediggoSearchConfig->install() && $this->registerHook('header') && $this->registerHook('top') && $this->registerHook('leftColumn') && $this->registerHook('rightColumn') && $this->registerHook('footer') && $this->registerHook('authentication') && $this->registerHook('createAccount') && $this->registerHook('backOfficeHeader') && $this->registerHook('paymentTop'); }
/** * @before _secure, changeLayout, _admin */ public function fbapps() { $this->seo(array("title" => "FBApps", "view" => $this->getLayoutView())); $view = $this->getActionView(); if (RequestMethods::post("action") == "fbapps") { $fbapp = new Meta(array("user_id" => $this->user->id, "property" => "fbapp", "value" => RequestMethods::post("fbapp"))); $fbapp->save(); $view->set("message", "FBApp Added Successfully"); } $fbapps = Meta::all(array("property=?" => "fbapp")); $view->set("fbapps", $fbapps); }
/** * Registers rewrite urls for frontend controller * @return bool */ public function registerUrls() { try { foreach (Language::getLanguages() as $language) { $data = Meta::getMetaByPage('module-newsletter2go-Export', $language['id_lang']); $meta = new Meta($data['id_meta']); if ($meta && $meta->id) { $meta->url_rewrite = 'n2go-export'; $meta->save(); } } } catch (Exception $e) { return false; } return true; }
/** * 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->aMeta !== null) { if ($this->aMeta->isModified() || $this->aMeta->isNew()) { $affectedRows += $this->aMeta->save($con); } $this->setMeta($this->aMeta); } if ($this->isNew()) { $this->modifiedColumns[] = PartsPeer::ID; } // If this object has been modified, then save it to the database. if ($this->isModified()) { if ($this->isNew()) { $pk = PartsPeer::doInsert($this, $con); $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which // should always be true here (even though technically // BasePeer::doInsert() can insert multiple rows). $this->setId($pk); //[IMV] update autoincrement primary key $this->setNew(false); } else { $affectedRows += PartsPeer::doUpdate($this, $con); } $this->resetModified(); // [HL] After being saved an object is no longer 'modified' } if ($this->collPhotoss !== null) { foreach ($this->collPhotoss as $referrerFK) { if (!$referrerFK->isDeleted()) { $affectedRows += $referrerFK->save($con); } } } $this->alreadyInSave = false; } return $affectedRows; }
/** * @before _session */ public function preregister() { $this->seo(array("title" => "Register", "view" => $this->getLayoutView())); if (RequestMethods::post("action") == "patient") { $user = $this->_addUser(); $headers = getallheaders(); if ($user) { $meta = new Meta(array("user_id" => $user->id, "property" => "forgotPass", "value" => uniqid())); $meta->save(); Mail::notify(array("template" => "patientRegister", "subject" => "Welcome to HealthLitmus.com", "user" => $user, "meta" => $meta, "verify" => true)); if (isset($headers['X-Patient-App'])) { $view->set("message", "Registered successfully!! Check Email"); } else { $this->redirect("/patient/success"); } } else { $view->set("message", "Email / Phone already exists"); } } }
function criarprojeto() { $this->valida_sessao(); $nome_projeto = $this->escape("nomeproj"); $usuario = $this->escape("user"); $numero_profissionais = 10; $custo_padrao_hora = 50; $p_analise = 10; $p_projeto = 25; $p_implementacao = 50; $p_testes = 15; //cod: 10 - 20 - 55 - 15 //art: 30 - 27 - 15 - 28 $projeto = new Projeto(); $projeto->idUsuario = $usuario; $projeto->nome = $nome_projeto; $projeto->linhasDeCodigoPrevistas = rand(300000, 600000); $projeto->artefatosPrevistos = $projeto->linhasDeCodigoPrevistas * (1 / 100); //1% do codigo $projeto->tempo = round($projeto->linhasDeCodigoPrevistas / ($numero_profissionais * 194 * 5)); $projeto->orcamento = $numero_profissionais * $custo_padrao_hora * 8 * 5 * $projeto->tempo * 1.12; //custo esperado + 12% $projeto->saldo = $projeto->orcamento; $projeto->percentualErros = 1.5; $projeto->idStatus = 0; $projeto->save(); $meta1 = new Meta(); $meta1->nome = "Análise"; $meta1->idProjeto = $projeto->idProjeto; $meta1->tempo = round($projeto->tempo * ($p_analise / 100)); $meta1->linhasDeCodigo = round($projeto->linhasDeCodigoPrevistas * (10 / 100)); $meta1->artefatos = round($projeto->artefatosPrevistos * (30 / 100)); $meta1->save(); $meta2 = new Meta(); $meta2->nome = "Projeto"; $meta2->idProjeto = $projeto->idProjeto; $meta2->tempo = round($projeto->tempo * ($p_projeto / 100)); $meta2->linhasDeCodigo = round($projeto->linhasDeCodigoPrevistas * (20 / 100)); $meta2->artefatos = round($projeto->artefatosPrevistos * (27 / 100)); $meta2->save(); $meta3 = new Meta(); $meta3->nome = "Implementação"; $meta3->idProjeto = $projeto->idProjeto; $meta3->tempo = round($projeto->tempo * ($p_implementacao / 100)); $meta3->linhasDeCodigo = round($projeto->linhasDeCodigoPrevistas * (55 / 100)); $meta3->artefatos = round($projeto->artefatosPrevistos * (15 / 100)); $meta3->save(); $meta4 = new Meta(); $meta4->nome = "Testes e Validação"; $meta4->idProjeto = $projeto->idProjeto; $meta4->tempo = $projeto->tempo - $meta3->tempo - $meta2->tempo - $meta1->tempo; $meta4->linhasDeCodigo = $projeto->linhasDeCodigoPrevistas - $meta3->linhasDeCodigo - $meta2->linhasDeCodigo - $meta1->linhasDeCodigo; $meta4->artefatos = $projeto->artefatosPrevistos - $meta3->artefatos - $meta2->artefatos - $meta1->artefatos; $meta4->save(); for ($i = 0; $i < $projeto->tempo; $i++) { $semana = new Semana(); $semana->idProjeto = $projeto->idProjeto; $semana->save(); for ($j = 0; $j < 5; $j++) { $dia = new Dia(); $dia->idSemana = $semana->idSemana; $dia->save(); } } $_SESSION["idprojeto"] = $projeto->idProjeto; $_SESSION["projeto"] = true; $apresentacao = $this->escape("apresentacao"); if ($apresentacao == true) { $this->set("apresentacao", true); } else { $this->set("apresentacao", false); } $this->show("pages/interno/index.tpl"); }
public function createAuthCode() { // Save random auth code in users meta data $authcode = Crypt::hash("random:authcode:" . DateManager::now() . ":" . rand()); Meta::remove("user", $this->id, "authcode"); Meta::save("user", $this->id, "authcode", Crypt::createHash($authcode)); }
/** * Sets the meta for app login */ private function _meta($user, $app) { $meta = Meta::first(array("property = ?" => "user", "property_id = ?" => $user->id, "meta_key = ?" => $app . "-app")); if (!$meta) { $meta = new Meta(array("property" => "user", "property_id" => $user->id, "meta_key" => $app . "-app", "meta_value" => Markup::uniqueString(44))); $meta->save(); } return $meta; }
/** * @before _secure * @after _csrfToken */ public function settings() { $this->seo(array("title" => "Settings")); $view = $this->getActionView(); $user = $this->user; $org = $this->org; $search = ['prop' => 'customField', 'propid' => $org->_id]; $meta = Meta::first($search) ?? (object) []; $view->set('fields', $meta->value ?? []); $apikey = ApiKey::first(["org_id = ?" => $org->id]); $mailConf = Meta::first(['prop' => 'orgSmtp', 'propid' => $this->org->_id]) ?? (object) []; $view->set('mailConf', $mailConf->value ?? [])->set("errors", []); if (RM::type() == 'POST') { $action = RM::post('action', ''); switch ($action) { case 'account': $user->name = RM::post('name'); $user->currency = RM::post('currency', 'INR'); $user->region = ["currency" => RM::post('currency', 'INR'), "zone" => RM::post('timezone', 'Asia/Kolkata')]; $user->phone = RM::post('phone'); $user->save(); $view->set('message', 'Account Updated!!'); break; case 'password': $old = RM::post('password'); $new = RM::post('npassword'); $view->set($user->updatePassword($old, $new)); break; case 'billing': $billing = $org->billing; $billing["aff"]["auto"] = RM::post("autoinvoice", 0); $billing["aff"]["freq"] = RM::post("freq", 15); $billing["aff"]["minpay"] = $this->currency(RM::post('minpay', 100)); $billing["aff"]["ptypes"] = RM::post("ptypes"); $billing["adv"]["paypal"] = RM::post("paypal"); $org->billing = $billing; $org->save(); $this->setOrg($org); $view->set('message', 'Organization Billing Updated!!'); break; case 'org': $meta = $org->meta; if (RM::post("widgets")) { $meta["widgets"] = RM::post("widgets"); $org->meta = $meta; } $zopim = RM::post("zopim"); $meta["zopim"] = $zopim; if (strlen($zopim) == 0) { unset($meta["zopim"]); } $org->name = RM::post('name'); $org->meta = $meta; $org->logo = $this->_upload('logo'); $org->url = RM::post('url'); $org->email = RM::post('email'); $org->save(); $this->setOrg($org); $view->set('message', 'Network Settings updated!!'); break; case 'customField': $label = RM::post("fname"); $type = RM::post("ftype", "text"); $required = RM::post("frequired", 1); $name = strtolower(str_replace(" ", "_", $label)); $field = ['label' => ucwords($label), 'type' => $type, 'name' => $name, 'required' => (bool) $required]; if (!$label) { break; } if (!is_object($meta) || !is_a($meta, 'Meta')) { $meta = new Meta($search); } $fields = $meta->value; $fields[] = $field; $meta->value = $fields; $meta->save(); $view->set('fields', $meta->value ?? []); $view->set('message', 'Extra Field Added!!'); break; case 'smtp': $msg = \Shared\Services\Smtp::create($this->org); $view->set('message', $msg); break; case 'apikey': $view->set('message', "Api Key Updated!!"); if (!$apikey) { $apikey = new ApiKey(['org_id' => $this->org->_id, 'key' => uniqid() . uniqid() . uniqid()]); $view->set('message', "Api Key Created!!"); } $apikey->updateIps(); $apikey->save(); break; } $this->setUser($user); } $view->set("apiKey", $apikey); if (RM::type() === 'DELETE') { if (is_a($meta, 'Meta')) { $meta->delete(); } $view->set('message', 'Extra Fields removed!!'); } $img = RM::get("img"); if (RM::get("action") == "removelogo" && $img === $org->logo) { Utils::media($org->logo, 'remove'); $org->logo = ' '; $this->setOrg($org); $org->save(); $this->redirect("/admin/settings.html"); } }
public function userRegister($request) { // Register new user from request if (empty($request['username'])) { return array("message" => array("type" => "error", "code" => "MandatoryInputMissing"), "missing_fields" => "username"); } $sql = new SqlManager(); $sql->setQuery("SELECT * FROM user WHERE username = '******'"); $sql->bindParam("{{username}}", $request['username']); $check = $sql->result(); if (isset($check['id'])) { return array("message" => array("type" => "error", "code" => "UsernameUsed")); } $newuser = new User(); $id = $newuser->create(array("username" => $request['username'])); if (!$id) { return array("message" => array("type" => "error", "code" => "UnknownError")); } $newuser->load($id); $groups = array(); if (isset($request['usergroups'])) { $groups = split(",", $request['usergroups']); } foreach ($groups as $group) { Meta::save("user", $newuser->getID(), "usergroup", $group); } $newuser->createAuthCode(); return array("redirect" => array("url" => "/bestaetige-account", "post" => array("username" => $request['username']))); }
/** * Install module's controllers using public property $controllers * @return bool */ protected function installControllers() { foreach ($this->controllers as $controller) { $page = 'module-' . $this->name . '-' . $controller; $result = Db::getInstance()->getValue('SELECT * FROM ' . _DB_PREFIX_ . 'meta WHERE page="' . pSQL($page) . '"'); if ((int) $result > 0) { continue; } $meta = new Meta(); $meta->page = $page; $meta->configurable = 1; $meta->save(); } return true; }
/** * @param $title * @param $url_rewrite * @param $description * @param string $keywords * @param string $controller * @return bool */ protected function installMeta($title, $url_rewrite, $description, $keywords = '', $controller = 'default') { $page_name = 'module-' . $this->name . '-' . $controller; $sql = 'SELECT count(page) as nbr FROM `' . _DB_PREFIX_ . 'meta` m WHERE m.`page` = "' . pSQL($page_name) . '"'; $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql); $result = (int) $result['nbr']; if ($result == 0) { $meta = new Meta(); foreach (Language::getLanguages(true) as $lang) { $id_lang = (int) $lang['id_lang']; $meta->title[$id_lang] = $this->l($title, true, $id_lang); $meta->url_rewrite[$id_lang] = $this->l($url_rewrite, true, $id_lang); $meta->keywords[$id_lang] = $this->l($keywords, true, $id_lang); $meta->description[$id_lang] = $this->l($description, true, $id_lang); } $meta->page = $page_name; if ($meta->save()) { return true; } } return true; }
/** * Register the doctor * @before _session */ public function preregister() { $this->seo(array("title" => "Doctor | Pre-Register", "view" => $this->getLayoutView())); $view = $this->getActionView(); $days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]; $view->set("specialities", self::$_specialities)->set("medicine", array("Allopathy", "Homeopathy", "Naturopathy"))->set("days", $days); if (RequestMethods::post("action") == "doctor") { $user = \User::saveRecord(null, false); if (is_array($user)) { $view->set("errors", $user); return; } $doc = \Doc::saveRecord($user, null, false); if (is_array($doc)) { $view->set("errors", $doc); return; } $location = \Location::saveRecord($user, null, true); if (is_array($location)) { unset($location["user_id"]); if (count($location) >= 1) { $view->set("errors", $location); return; } } try { $user->save(); $doc->user_id = $user->id; $doc->save(); $location->user_id = $user->id; $location->save(); $organization = Shared\Services\Doctor::createOrg(array("user" => $user, "location" => $location)); \Slot::saveRecord($user, $organization); } catch (\Exception $e) { $view->set("message", "Email or phone number exists"); return; } $meta = new Meta(array("user_id" => $user->id, "property" => "forgotPass", "value" => uniqid())); $meta->save(); Shared\Services\Mail::notify(array("template" => "doctorRegister", "subject" => "Welcome to HealthLitmus.com", "user" => $user, "meta" => $meta, "verify" => true)); $this->redirect("/auth/success"); } }
protected function _forgotPassword($org) { $exist = User::first(array("email = ?" => RM::post("email")), array("id", "email", "name")); if ($exist) { $meta = new Meta(array("propid" => $exist->id, "prop" => "resetpass", "value" => uniqid())); $meta->save(); Mail::send(array("template" => "forgotpass", "subject" => "New Password Requested", "user" => $exist, "meta" => $meta, "org" => $this->org)); } return "Password Reset Email Sent Check Your Email. Check in Spam too."; }
/** * Sets the meta for app login */ private function _meta($user, $app) { $meta = Meta::first(array("user_id = ?" => $user->id, "property = ?" => $app . "-app")); if (!$meta) { $meta = new Meta(array("user_id" => $user->id, "property" => $app . "-app", "value" => uniqid())); $meta->save(); } return $meta; }