/** * Set created_ properties for a given object if not set * * @param DataObject $object * @return null */ function system_handle_on_before_object_insert($object) { if ($object->fieldExists('created_on')) { if (!isset($object->values['created_on'])) { $object->setCreatedOn(new DateTimeValue()); } // if } // if $user =& get_logged_user(); if (!instance_of($user, 'User')) { return; } // if if ($object->fieldExists('created_by_id') && !isset($object->values['created_by_id'])) { $object->setCreatedById($user->getId()); } // if if ($object->fieldExists('created_by_name') && !isset($object->values['created_by_name'])) { $object->setCreatedByName($user->getDisplayName()); } // if if ($object->fieldExists('created_by_email') && !isset($object->values['created_by_email'])) { $object->setCreatedByEmail($user->getEmail()); } // if }
/** * Render select company box * * Parameters: * * - value - Value of selected company * - optional - Is value of this field optional or not * - exclude - Array of company ID-s that will be excluded * - can_create_new - Should this select box offer option to create a new * company from within the list * * @param array $params * @param Smarty $smarty * @return string */ function smarty_function_select_company($params, &$smarty) { static $ids = array(); $companies = Companies::getIdNameMap(array_var($params, 'companies')); $value = array_var($params, 'value', null, true); $id = array_var($params, 'id', null, true); if (empty($id)) { $counter = 1; do { $id = "select_company_dropdown_{$counter}"; $counter++; } while (in_array($id, $ids)); } // if $ids[] = $id; $params['id'] = $id; $optional = array_var($params, 'optional', false, true); $exclude = array_var($params, 'exclude', array(), true); if (!is_array($exclude)) { $exclude = array(); } // if $can_create_new = array_var($params, 'can_create_new', true, true); if ($optional) { $options = array(option_tag(lang('-- None --'), ''), option_tag('', '')); } else { $options = array(); } // if foreach ($companies as $company_id => $company_name) { if (in_array($company_id, $exclude)) { continue; } // if $option_attributes = array('class' => 'object_option'); if ($value == $company_id) { $option_attributes['selected'] = true; } // if $options[] = option_tag($company_name, $company_id, $option_attributes); } // if if ($can_create_new) { $logged_user = get_logged_user(); if (instance_of($logged_user, 'User') && Company::canAdd($logged_user)) { $params['add_object_url'] = assemble_url('people_companies_quick_add'); $params['object_name'] = 'company'; $params['add_object_message'] = lang('Please insert new company name'); $options[] = option_tag('', ''); $options[] = option_tag(lang('New Company...'), '', array('class' => 'new_object_option')); } // if } // if return select_box($options, $params) . '<script type="text/javascript">$("#' . $id . '").new_object_from_select();</script>'; }
/** * Show user card * * @param array $params * @param Smarty $smarty * @return string */ function smarty_function_user_card($params, &$smarty) { $user = array_var($params, 'user'); if (!instance_of($user, 'User')) { return new InvalidParamError('user', $user, '$user is expected to be an instance of User class', true); } // if $smarty->assign(array('_card_user' => $user, '_card_options' => $user->getOptions(get_logged_user()))); return $smarty->fetch(get_template_path('_card', 'users', SYSTEM_MODULE)); }
/** * Render company card * * Parameters: * * - company - company instance * * @param array $params * @param Smarty $smarty * @return string */ function smarty_function_company_card($params, &$smarty) { $company = array_var($params, 'company'); if (!instance_of($company, 'Company')) { return new InvalidParamError('company', $company, '$company is expected to be an valid Company instance', true); } // if $smarty->assign(array('_card_company' => $company, '_card_options' => $company->getOptions(get_logged_user()))); return $smarty->fetch(get_template_path('_card', 'companies', SYSTEM_MODULE)); }
function __construct() { $this->ci =& get_instance(); $session_user = get_logged_user(); if (empty($session_user)) { redirect('login/logout'); } $this->ci->load->helper("html"); $this->ci->load->helper("form_helper"); $this->ci->load->library('table'); $this->ci->load->model("screen_model"); $this->user_obj = unserialize($session_user); }
/** * Select project group helper * * Params: * * - value - ID of selected group * - optional - boolean * - can_create_new - Should this select box offer option to create a new * company from within the list * * @param array $params * @param Smarty $smarty * @return string */ function smarty_function_select_project_group($params, &$smarty) { static $ids = array(); $optional = array_var($params, 'optional', true, true); $value = array_var($params, 'value', null, true); $can_create_new = array_var($params, 'can_create_new', true, true); $id = array_var($params, 'id', null, true); if (empty($id)) { $counter = 1; do { $id = "select_project_group_dropdown_{$counter}"; $counter++; } while (in_array($id, $ids)); } // if $ids[] = $id; $params['id'] = $id; $groups = ProjectGroups::findAll($smarty->get_template_vars('logged_user'), true); if ($optional) { $options = array(option_tag(lang('-- None --'), ''), option_tag('', '')); } else { $options = array(); } // if if (is_foreachable($groups)) { foreach ($groups as $group) { $option_attributes = array('class' => 'object_option'); if ($value == $group->getId()) { $option_attributes['selected'] = true; } // if $options[] = option_tag($group->getName(), $group->getId(), $option_attributes); } // foreach } // if if ($can_create_new) { $params['add_object_url'] = assemble_url('project_groups_quick_add'); $params['object_name'] = 'project_group'; $params['add_object_message'] = lang('Please insert new project group name'); $logged_user = get_logged_user(); if (instance_of($logged_user, 'User') && ProjectGroup::canAdd($logged_user)) { $options[] = option_tag('', ''); $options[] = option_tag(lang('New Project Group...'), '', array('class' => 'new_object_option')); } // if } // if return select_box($options, $params) . '<script type="text/javascript">$("#' . $id . '").new_object_from_select();</script>'; }
/** * Render select Document Category helper * * Params: * * - Standard select box attributes * - value - ID of selected role * - optional - Wether value is optional or not * - can_create_new - Can the user create new category or not, default is true * * @param array $params * @param Smarty $smarty * @return string */ function smarty_function_select_document_category($params, &$smarty) { static $ids = array(); $user = array_var($params, 'user', null, true); if (!instance_of($user, 'User')) { return new InvalidParamError('user', $user, '$user is expected to be a valid User object', true); } // if $value = array_var($params, 'value', null, true); $can_create_new = array_var($params, 'can_create_new', true, true); $id = array_var($params, 'id', null, true); if (empty($id)) { $counter = 1; do { $id = "select_document_category_dropdown_{$counter}"; $counter++; } while (in_array($id, $ids)); } // if $ids[] = $id; $params['id'] = $id; $options = array(); $categories = DocumentCategories::findAll($user); if (is_foreachable($categories)) { foreach ($categories as $category) { $option_attributes = array('class' => 'object_option'); if ($value == $category->getId()) { $option_attributes['selected'] = true; } // if $options[] = option_tag($category->getName(), $category->getId(), $option_attributes); } // foreach } // if if ($can_create_new) { $params['add_object_url'] = assemble_url('document_categories_quick_add'); $params['object_name'] = 'document_category'; $params['add_object_message'] = lang('Please insert new document category name'); $logged_user = get_logged_user(); if (instance_of($logged_user, 'User') && DocumentCategory::canAdd($logged_user)) { $options[] = option_tag('', ''); $options[] = option_tag(lang('New Category...'), '', array('class' => 'new_object_option')); } // if } // if return select_box($options, $params) . '<script type="text/javascript">$("#' . $id . '").new_object_from_select();</script>'; }
public function generate() { $this->ci->add_asset("assets/cube/css/libs/dropzone_base.css", "css"); $this->ci->add_asset("assets/cube/js/dropzone.min.js"); $this->ci->add_asset("assets/js/modules/gallery.js"); $url = site_url("screen/component_execute_ajax/" . $this->config["to_table"] . "/gallery"); $session_user = unserialize(get_logged_user()); $image_path = $session_user->upload_path; $action_url = site_url("screen/galery_image_upload"); $result = <<<EOT \t\t</div> \t\t</div> \t\t\t<input type="hidden" id="ajax_url" value="{$url}" /> \t\t\t<input type="hidden" id="image_path" value="{$image_path}" /> \t\t\t\t<div class="main-box"> \t\t\t\t\t<header class="main-box-header"> \t\t\t\t\t\t<h2>GALERIA DE IMAGENS</h2> \t\t\t\t\t\t<p> \t\t\t\t\t\t<i class="fa fa-info-circle"></i> Clique na caixa cinza, ou arraste imagens para cadastrar imagens para a galeria \t\t\t\t\t\t</p> \t\t\t\t\t</header> \t\t\t\t\t<div class="main-box-body"> \t\t\t\t\t\t<div id="dropzone"> \t\t\t\t\t\t\t<form id="demo_upload" class="dropzone2 dz-clickable" action="{$action_url}"> \t\t\t\t\t\t\t\t<div class="dz-default dz-message"> \t\t\t\t\t\t\t\t\t<span>Arraste imagens aqui</span> \t\t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t</form> \t\t\t\t\t\t</div> \t\t\t\t\t</div> \t\t\t\t</div> \t\t\t\t<div class="main-box"> \t\t\t\t\t<header class="main-box-header"> \t\t\t\t\t\t<h2><i class="fa fa-camera"></i> Imagens cadastradas, clique nelas pare deletar</h2> \t\t\t\t\t</header> \t\t\t\t\t \t\t\t\t\t<div class="main-box-body"> \t\t\t\t\t\t<div id="gallery-photos-wrapper"> \t\t\t\t\t\t\t<ul id="gallery-photos" class="clearfix gallery-photos gallery-photos-hover"> \t\t\t\t\t\t\t\t \t\t\t\t\t\t\t</ul> \t\t\t\t\t\t</div> EOT; return $result; }
function change_selected_company($company_id = false) { if ($this->data["logged_user"]->developer == 1) { $database_company = $this->company_model->get($company_id); $session_user = unserialize(get_logged_user()); $session_user->company_id = $company_id; //$this->input->post("company_id"); $session_user->profile_id = $database_company->profile_id; $session_user->upload_path = $database_company->upload_path; // dump($session_user); $_SESSION["user"] = serialize($session_user); $_SESSION["logged_user"] = serialize($session_user); $this->session->set_userdata('user', serialize($session_user)); } redirect("dashboard"); }
function get($id = false) { $this->object = unserialize(get_logged_user()); if (!$id) { $id = $this->object->user_id; } $this->db->select("users.*, users.level, roles.title as role, roles.id as role_id, roles.title as role"); $this->db->from("users"); $this->db->join("company", "company.id = users.company_id"); $this->db->join('user_roles', 'users.id = user_roles.user_id', 'left'); $this->db->join('roles', 'user_roles.role_id = roles.id', 'left'); $user = (array) $this->db->where("users.id", $id)->get()->row(); $this->db->select("user_information.*, state.id as state_id, state.letter as state_letter"); $this->db->from('user_information'); $this->db->join('zone', 'zone.id = user_information.zone_id', 'left'); $this->db->join('state', 'state.id = zone.id_state', 'left'); $this->db->where('user_id', $user["id"]); $address = (array) $this->db->get()->row(); // dump($address); return (object) array_merge($user, $address); }
/** * Show users local time based on his or hers local settings * * Parameters: * * - user - User, if NULL logged user will be used * - datetime - Datetime value that need to be displayed. If NULL request time * will be used * * @param array $params * @param Smarty $smarty * @return string */ function smarty_function_user_time($params, &$smarty) { $user = array_var($params, 'user'); if (!instance_of($user, 'User')) { $user = get_logged_user(); } // if if (!instance_of($user, 'User')) { return lang('Unknown time'); } // if $value = array_var($params, 'datetime'); if (!instance_of($value, 'DateValue')) { $value = $smarty->get_template_vars('request_time'); } // if if (!instance_of($value, 'DateValue')) { return lang('Unknown time'); } // if require_once SMARTY_PATH . '/plugins/modifier.time.php'; return clean(smarty_modifier_time($value, get_user_gmt_offset($user))); }
/** * Render select role helper * * Params: * * - value - ID of selected role * - optional - Wether value is optional or not * - active_user - Set if we are changing role of existing user so we can * handle situations when administrator role is displayed or changed * * @param array $params * @param Smarty $smarty * @return string */ function smarty_function_select_role($params, &$smarty) { $value = array_var($params, 'value', null, true); $optional = array_var($params, 'optional', false, true); $active_user = array_var($params, 'active_user', false, true); $logged_user = get_logged_user(); if (!instance_of($logged_user, 'User')) { return new InvalidParamError('logged_user', $logged_user, '$logged_user is expected to be an instance of user class'); } // if if ($optional) { $options = array(option_tag(lang('-- None --'), ''), option_tag('', '')); } else { $options = array(); } // if $roles = Roles::findSystemRoles(); if (is_foreachable($roles)) { foreach ($roles as $role) { $show_role = true; $disabled = false; if ($role->getPermissionValue('admin_access') && !$logged_user->isAdministrator() && !$active_user->isAdministrator()) { $show_role = false; // don't show administration role to non-admins and for non-admins } // if if ($show_role) { $option_attributes = $value == $role->getId() ? array('selected' => true, 'disabled' => $disabled) : null; $options[] = option_tag($role->getName(), $role->getId(), $option_attributes); } // if } // foreach } // if return select_box($options, $params); }
public function show($options = array(), $data) { $this->set_options((array) $data["options"]); $this->get_options(); if (trim($data['value']) == "") { return img("http://www.placehold.it/" . $this->max_list_size . "x" . $this->max_list_size . "/EFEFEF/AAAAAA"); } // $image = ""; // $value = explode(".",$data["value"]); // $ext = end($value); // $i=0; // foreach ($value as $val) { // if($i == (count($value)-1)){ // $image .= "_thumb.".$val; // }else{ // $image .= "{$val}"; // } // $i++; // } $session_user = unserialize(get_logged_user()); // dump($session_user); $options = array("src" => $session_user->upload_path . $data["value"], "width" => $this->max_list_size . "px", "height" => $this->max_list_size . "px"); return img($options); }
function order_details($id) { $this->page_title = "Order Details | General Tech Services LLC -" . STATIC_TITLE; if ($id) { $orderInfo = $this->user_model->getOrder(get_logged_user('id'), $id); $this->render_page(strtolower(__CLASS__) . '/order_details', $orderInfo); } }
/** * Change invoice status * * @param integer $status * @param User $by * @param DateValue $on * @return null */ function setStatus($status, $by = null, $on = null) { $on = instance_of($on, 'DateValue') ? $on : new DateValue(); $by = instance_of($by, 'User') ? $by : get_logged_user(); switch ($status) { // Mark invoice as draft case INVOICE_STATUS_DRAFT: parent::setStatus($status); $this->setIssuedOn(null); $this->setIssuedById(null); $this->setIssuedByName(null); $this->setIssuedByEmail(null); $this->setClosedOn(null); $this->setClosedById(null); $this->setClosedByName(null); $this->setClosedByEmail(null); break; // Mark invoice as issued // Mark invoice as issued case INVOICE_STATUS_ISSUED: parent::setStatus($status); if ($on) { $this->setIssuedOn($on); } // if if ($by) { $this->setIssuedById($by->getId()); $this->setIssuedByName($by->getName()); $this->setIssuedByEmail($by->getEmail()); } // if $this->setClosedOn(null); $this->setClosedById(null); $this->setClosedByName(null); $this->setClosedByEmail(null); $this->setTimeRecordsStatus(BILLABLE_STATUS_PENDING_PAYMENT); break; // Mark invoice as billed // Mark invoice as billed case INVOICE_STATUS_BILLED: parent::setStatus(INVOICE_STATUS_BILLED); $this->setClosedOn($on); $this->setClosedById($by->getId()); $this->setClosedByName($by->getName()); $this->setClosedByEmail($by->getEmail()); $this->setTimeRecordsStatus(BILLABLE_STATUS_BILLED); break; // Mark invoice as canceled // Mark invoice as canceled case INVOICE_STATUS_CANCELED: parent::setStatus(INVOICE_STATUS_CANCELED); $this->setClosedOn($on); $this->setClosedById($by->getId()); $this->setClosedByName($by->getName()); $this->setClosedByEmail($by->getEmail()); InvoicePayments::deleteByInvoice($this); $this->setTimeRecordsStatus(BILLABLE_STATUS_BILLABLE); $this->releaseTimeRecords(); break; default: return new InvalidParamError('status', $status, '$status is not valid invoice status', true); } // switch }
function create_new_ad_action() { $this->load->model("user_model"); $id = @$this->input->post('ad_id', TRUE); set_message("Anuncio criado com sucesso"); $this->ad_model->post_to_values($this->input->post("ad")); if (!$this->ad_model->valid) { die("validar"); } if ($id) { set_message("Anuncio editado com sucesso"); // verifica antes se o id eh do usuario mesmo $this->ad_model->get($id); if ($this->ad_model->is_mine()) { $this->ad_model->post_to_values($this->input->post("ad")); $this->ad_model->update($id); } } else { $this->ad_model->object->user_id = unserialize(get_logged_user())->user_id; $this->ad_model->create_new($this->ad_model->object); } // inserir subcategorias // veiculo $this->ad_vehicle_model->post_to_values(@$this->input->post("vehicle")); if (!empty($this->ad_vehicle_model->object)) { if ($this->ad_vehicle_model->is_valid()) { $this->ad_vehicle_model->create_or_update($this->ad_model->object->vehicle_id); $this->ad_model->set_vehicle_id($this->ad_vehicle_model->object->id); } else { // voltar pra tela como erro die("temos um problema "); } } $this->user_model->update_user($this->input->post("user")); // updatear imagens $this->ad_image_model->set_ad_images($this->input->post('image'), $this->ad_model->object->id); redirect(site_url("lib_generic/method/anuncios/ad/home_page")); }
/** * Return user GMT offset * * Return number of seconds that current user is away from the GMT. If user is * not logged in this function should return system offset * * @param User $user * @return integer */ function get_user_gmt_offset($user = null) { static $offset = array(); if (!instance_of($user, 'User')) { $user = get_logged_user(); } // if if (!instance_of($user, 'User')) { return get_system_gmt_offset(); } // if if (!isset($offset[$user->getId()])) { $timezone_offset = UserConfigOptions::getValue('time_timezone', $user); $dst = UserConfigOptions::getValue('time_dst', $user); $offset[$user->getId()] = $dst ? $timezone_offset + 3600 : $timezone_offset; } // if return $offset[$user->getId()]; }
/** * Initialize locale settings based on logged in user * * @param void * @return null */ function init_locale() { // Used when application is initialized from command line (we don't have // all the classes available) if (!class_exists('ConfigOptions') || !class_exists('UserConfigOptions')) { return true; } // if $logged_user =& get_logged_user(); $language_id = null; if (instance_of($logged_user, 'User')) { if (LOCALIZATION_ENABLED) { $language_id = UserConfigOptions::getValue('language', $logged_user); } // if $format_date = UserConfigOptions::getValue('format_date', $logged_user); $format_time = UserConfigOptions::getValue('format_time', $logged_user); } else { if (LOCALIZATION_ENABLED) { $language_id = ConfigOptions::getValue('language'); } // if $format_date = ConfigOptions::getValue('format_date'); $format_time = ConfigOptions::getValue('format_time'); } // if $language = new Language(); // Now load languages if (LOCALIZATION_ENABLED && $language_id) { $language = Languages::findById($language_id); if (instance_of($language, 'Language')) { $current_locale = $language->getLocale(); $GLOBALS['current_locale'] = $current_locale; $GLOBALS['current_locale_translations'] = array(); if ($current_locale != BUILT_IN_LOCALE) { setlocale(LC_ALL, $current_locale); // Set locale // workaround for tr, ku, az locales according to http://bugs.php.net/bug.php?id=18556 $current_locale_country = explode('.', $current_locale); $current_locale_country = strtolower($current_locale_country[0]); if (in_array($current_locale_country, array('tr_tr', 'ku', 'az_az'))) { setlocale(LC_CTYPE, BUILT_IN_LOCALE); } // if $GLOBALS['current_locale_translations'][$current_locale] = array(); $language->loadTranslations($current_locale); } // if } // if } // if $this->smarty->assign('current_language', $language); define('USER_FORMAT_DATETIME', "{$format_date} {$format_time}"); define('USER_FORMAT_DATE', $format_date); define('USER_FORMAT_TIME', $format_time); return true; }
function save_operation($wallet_id, $proper_amount_income, $income_date, $proper_amount_outcome, $outcome_category, $outcome_date) { is_numeric($proper_amount_income) ? $proper_amount_income = $proper_amount_income : ($proper_amount_income = 0); is_numeric($proper_amount_outcome) ? $proper_amount_outcome = $proper_amount_outcome : ($proper_amount_outcome = 0); increase_decrease_in_wallet($wallet_id, $proper_amount_income, $proper_amount_outcome); if ($proper_amount_income > 0) { $sql = " INSERT INTO operations SET\n us_id = " . get_logged_user() . ",\n wallet_id = " . $wallet_id . ",\n amount = " . $proper_amount_income . ",\n type = 'I',\n when_created = '" . date("Y-m-d", strtotime($income_date)) . "'"; mysql_query($sql); } if ($proper_amount_outcome > 0) { $sql = " INSERT INTO operations SET\n us_id = " . get_logged_user() . ",\n wallet_id = " . $wallet_id . ",\n amount = " . $proper_amount_outcome . ",\n category_id = " . $outcome_category . ",\n type = 'O',\n when_created = '" . date("Y-m-d", strtotime($outcome_date)) . "'"; mysql_query($sql); } }
function set_ad_images($images, $ad) { foreach ($images as $image) { $this->get_db()->update('ad_image', array("ad_id" => $ad), array("image_name" => $image, "user_id" => unserialize(get_logged_user())->user_id)); } }
function number_pager_display() { $user_id = unserialize(get_logged_user())->user_id; $result_set = $this->get_db()->from("ad")->where("is_deleted", 0)->where("user_id", $user_id)->order_by('created_at', 'DESC')->get(); // dump($result_set->num_rows/10); return ceil($result_set->num_rows / $this->itens_per_page); }
/** * Set page properties with following object * * Parameters: * * - object - Application object instance * * @param array $params * @param Smarty $smarty * @return null */ function smarty_function_page_object($params, &$smarty) { static $private_roles = false; $object = array_var($params, 'object'); if (!instance_of($object, 'ApplicationObject')) { return new InvalidParamError('object', $object, '$object is expected to be an instance of ApplicationObject class', true); } // if require_once SMARTY_DIR . '/plugins/modifier.datetime.php'; $wireframe =& Wireframe::instance(); $logged_user =& get_logged_user(); $construction =& PageConstruction::instance(); if ($construction->page_title == '') { $construction->setPageTitle($object->getName()); } // if if (instance_of($object, 'ProjectObject') && $wireframe->details == '') { $in = $object->getParent(); $created_on = $object->getCreatedOn(); $created_by = $object->getCreatedBy(); if (instance_of($created_by, 'User') && instance_of($in, 'ApplicationObject') && instance_of($created_on, 'DateValue')) { //BOF:mod 20120913 /* //EOF:mod 20120913 $wireframe->details = lang('By <a href=":by_url">:by_name</a> in <a href=":in_url">:in_name</a> on <span>:on</span>', array( //BOF:mod 20120913 */ $wireframe->details = lang('Created on <span>:on</span>', array('by_url' => $created_by->getViewUrl(), 'by_name' => $created_by->getDisplayName(), 'in_url' => $in->getViewUrl(), 'in_name' => $in->getName(), 'on' => smarty_modifier_datetime($created_on))); } elseif (instance_of($created_by, 'User') && instance_of($created_on, 'DateValue')) { //BOF:mod 20120913 /* //EOF:mod 20120913 $wireframe->details = lang('By <a href=":by_url">:by_name</a> on <span>:on</span>', array( //BOF:mod 20120913 */ $wireframe->details = lang('Created on <span>:on</span>', array('by_url' => $created_by->getViewUrl(), 'by_name' => $created_by->getDisplayName(), 'on' => smarty_modifier_datetime($created_on))); } elseif (instance_of($created_by, 'User')) { //BOF:mod 20120913 /* //EOF:mod 20120913 $wireframe->details = lang('By <a href=":by_url">:by_name</a>', array( //BOF:mod 20120913 */ $wireframe->details = lang('Created on <span>:on</span>', array('by_url' => $created_by->getViewUrl(), 'by_name' => $created_by->getDisplayName(), 'on' => smarty_modifier_datetime($created_on))); } elseif (instance_of($created_by, 'AnonymousUser') && instance_of($created_on, 'DateValue')) { //BOF:mod 20120913 /* //EOF:mod 20120913 $wireframe->details = lang('By <a href=":by_url">:by_name</a> on <span>:on</span>', array( //BOF:mod 20120913 */ $wireframe->details = lang('Created on <span>:on</span>', array('by_url' => 'mailto:' . $created_by->getEmail(), 'by_name' => $created_by->getName(), 'on' => smarty_modifier_datetime($created_on))); } elseif (instance_of($created_by, 'AnonymousUser')) { //BOF:mod 20120913 /* //EOF:mod 20120913 $wireframe->details = lang('By <a href=":by_url">:by_name</a>', array( //BOF:mod 20120913 */ $wireframe->details = lang('Created on <span>:on</span>', array('by_url' => 'mailto:' . $created_by->getEmail(), 'by_name' => $created_by->getName(), 'on' => smarty_modifier_datetime($created_on))); } // if } // if $smarty->assign('page_object', $object); // Need to do a case sensitive + case insensitive search to have PHP4 covered $class_methods = get_class_methods($object); if (in_array('getOptions', $class_methods) || in_array('getoptions', $class_methods)) { $options = $object->getOptions($logged_user); if (instance_of($options, 'NamedList') && $options->count()) { $wireframe->addPageAction(lang('Options'), '#', $options->data, array('id' => 'project_object_options'), 1000); } // if if (instance_of($object, 'ProjectObject')) { if ($object->getState() > STATE_DELETED) { if ($object->getVisibility() <= VISIBILITY_PRIVATE) { //Ticket ID #362 - modify Private button (SA) 14March2012 BOF $users_table = TABLE_PREFIX . 'users'; $assignments_table = TABLE_PREFIX . 'assignments'; $subscription_table = TABLE_PREFIX . 'subscriptions'; // $rows = db_execute_all("SELECT $assignments_table.is_owner AS is_assignment_owner, $users_table.id AS user_id, $users_table.company_id, $users_table.first_name, $users_table.last_name, $users_table.email FROM $users_table, $assignments_table WHERE $users_table.id = $assignments_table.user_id AND $assignments_table.object_id = ? ORDER BY $assignments_table.is_owner DESC", $object->getId()); $rows = db_execute_all("SELECT {$assignments_table}.is_owner AS is_assignment_owner, {$users_table}.id AS user_id, {$users_table}.company_id, {$users_table}.first_name, {$users_table}.last_name, {$users_table}.email FROM {$users_table}, {$assignments_table} WHERE {$users_table}.id = {$assignments_table}.user_id AND {$assignments_table}.object_id = " . $object->getId() . " UNION SELECT '0' AS is_assignment_owner, {$users_table}.id AS user_id, {$users_table}.company_id, {$users_table}.first_name, {$users_table}.last_name, {$users_table}.email FROM {$users_table}, {$subscription_table} WHERE {$users_table}.id = {$subscription_table}.user_id AND {$subscription_table}.parent_id = " . $object->getId()); if (is_foreachable($rows)) { $owner = null; $other_assignees = array(); $users_dropdown_for_tickets = ''; foreach ($rows as $row) { if (empty($row['first_name']) && empty($row['last_name'])) { $user_link = clean($row['email']); } else { $user_link = clean($row['first_name'] . ' ' . $row['last_name']); } // if if ($row['is_assignment_owner']) { $owner = $user_link; } else { $other_assignees[] = $user_link; } if ($owner) { if (instance_of($object, 'Ticket')) { if (count($other_assignees) > 0) { $users = $owner; if (!empty($users)) { $users .= ', '; } $users .= implode(', ', $other_assignees); } else { $users = $owner; } // if } else { if (count($other_assignees) > 0) { $users = $owner . ' ' . lang('is responsible', null, true, $language) . '. ' . lang('Other assignees', null, true, $language) . ': ' . implode(', ', $other_assignees) . '.'; } else { $users = $owner . ' ' . lang('is responsible', null, true, $language) . '.'; } // if } } elseif (count($other_assignees) > 0) { $users = implode(', ', $other_assignees); } } } $wireframe->addPageMessage(lang('<b>Private</b> - This Ticket has been marked as "Private" and is Visible by these Users: :users', array('users' => $users)), PAGE_MESSAGE_PRIVATE); //Ticket ID #362 - modify Private button (SA) 14March2012 EOF } // if } else { $wireframe->addPageMessage(lang('<b>Trashed</b> - this :type is located in trash.', array('type' => $object->getVerboseType(true))), PAGE_MESSAGE_TRASHED); } // if } // if } // if return ''; }
/** * Save this payment * * @param void * @return null */ function save() { db_begin_work(); $invoice = $this->getInvoice(); if (!instance_of($invoice, 'Invoice')) { return new Error('$invoice is not valid instance of Invoice class', true); } // if $save = parent::save(); if ($save && !is_error($save)) { if ($invoice->getMaxPayment(false) == 0 && $invoice->isIssued()) { $invoice->setStatus(INVOICE_STATUS_BILLED, get_logged_user(), $this->getPaidOn()); $save = $invoice->save(); if ($save && !is_error($save)) { $logged_user = get_logged_user(); if ($this->send_notification) { $issued_to_user = $invoice->getIssuedTo(); if (instance_of($issued_to_user, 'User')) { $notify_users = array($logged_user); if ($issued_to_user->getId() != $logged_user->getId()) { $notify_users[] = $issued_to_user; } // if ApplicationMailer::send($notify_users, 'invoicing/billed', array('closed_by_name' => $logged_user->getDisplayName(), 'closed_by_url' => $logged_user->getViewUrl(), 'invoice_number' => $invoice->getNumber(), 'invoice_url' => $invoice->getCompanyViewUrl())); } // if } // if db_commit(); return true; } else { db_rollback(); return $save; } // if } // if db_commit(); return true; } else { db_rollback(); return $save; } // if }
/** * Return real view URL * * @param void * @return string */ function getRealViewUrl($add_page = false) { if ($this->real_view_url === false) { if ($this->getState() == STATE_DELETED) { $this->real_view_url = assemble_url('trash'); } // if $parent = $this->getParent(); if (!instance_of($parent, 'ProjectObject')) { return new InvalidInstanceError('parent', $parent, 'ProjectObject', 'Parent is expected to be an instance of ProjectObject class'); } // if if ($parent->comments_per_page) { $logged_user = get_logged_user(); $page = ceil(Comments::findCommentNum($this, $parent->getState(), $logged_user->getVisibility()) / $parent->comments_per_page); if ($add_page) { $link = mysql_connect(DB_HOST, DB_USER, DB_PASS); mysql_select_db(DB_NAME); $query = "select * from healingcrystals_project_objects where type='Comment' and parent_id='" . $parent->getId() . "' and state='" . STATE_VISIBLE . "' and visibility='" . VISIBILITY_NORMAL . "' order by created_on desc"; $result = mysql_query($query, $link); $count = 0; while ($info = mysql_fetch_assoc($result)) { $count++; if ($info['id'] == $this->getId()) { break; } } if (!empty($count)) { $page = ceil($count / $parent->comments_per_page); } mysql_close($link); //19 March2012 (SA) Ticket #760: fix broken permalinksBOF $this->real_view_url = $parent->getViewUrl($page) . '&show_all=1#comment' . $this->getId(); } else { $this->real_view_url = $parent->getViewUrl() . '&show_all=1#comment' . $this->getId(); } } else { $this->real_view_url = $parent->getViewUrl() . '&show_all=1#comment' . $this->getId(); //19 March2012 (SA) Ticket #760: fix broken permalinks EOF } // if } // if return $this->real_view_url; }
/** * Save into database * * @return boolean */ function save() { if ($this->isNew()) { $this->setTicketId(Tickets::findNextTicketIdByProject($this->getProjectId())); } // if $changes = null; if ($this->isLoaded()) { $log_fields = array('project_id', 'milestone_id', 'parent_id', 'name', 'body', 'priority', 'due_on', 'completed_on'); $changes = new TicketChange(); $changes->setTicketId($this->getId()); $changes->setVersion($this->getVersion()); $changes->setCreatedOn(DateTimeValue::now()); $changes->setCreatedBy(get_logged_user()); if ($this->new_assignees !== false) { list($old_assignees, $old_owner_id) = $this->getAssignmentData(); if (is_array($this->new_assignees) && isset($this->new_assignees[0]) && isset($this->new_assignees[1])) { $new_assignees = $this->new_assignees[0]; $new_owner_id = $this->new_assignees[1]; } else { $new_assignees = array(); $new_owner_id = 0; } // if if ($new_owner_id != $old_owner_id) { $changes->addChange('owner', $old_owner_id, $new_owner_id); } // if sort($new_assignees); sort($old_assignees); if ($new_assignees != $old_assignees) { $changes->addChange('assignees', $old_assignees, $new_assignees); } // if } // if foreach ($this->modified_fields as $field) { if (!in_array($field, $log_fields)) { continue; } // if $old_value = array_var($this->old_values, $field); $new_value = array_var($this->values, $field); if ($old_value != $new_value) { $changes->addChange($field, $old_value, $new_value); } // if } // foreach } // if $save = parent::save(); if ($save && !is_error($save)) { if (instance_of($changes, 'TicketChange') && count($changes->changes)) { $this->changes = false; $changes->save(); } // if } // if return $save; }
<?php include '../utils/db.php'; $logged_user = get_logged_user(); $operation_id = $_GET['id']; if ($logged_user == 0) { header('Location: index.php'); } delete_savings_operation($operation_id, $logged_user); header('Location: ../portal.php?page=wallet_savings&o=M');
/** * Add new entry to the log * * @param ProjectObject $object * @param User $by * @param string $comment * @return null */ function log($object, $by = null, $comment = null) { $this->setType(get_class($this)); $this->setObjectId($object->getId()); $this->setProjectId($object->getProjectId()); if ($by === null) { $by = get_logged_user(); } // if $this->setCreatedBy($by); $this->setCreatedOn(new DateTimeValue()); if ($comment) { $this->setComment($comment); } // if return $this->save(); }
private static function _generateCacheKey($request) { $key = self::$_cacheKeyPrefix; if (isset($request->three_o_four_cache_opts['store_per_user']) && $request->three_o_four_cache_opts['store_per_user'] == true) { $key .= '_u' . get_logged_user()->values['id']; } if ($request->isApiCall()) { $key .= '_api'; } $key .= '_' . str_replace('/', '-', trim(ANGIE_PATH_INFO, '/')); //var_dump($request->getUrlParams()); //die(); $urlParams = $request->getUrlParams(); if (isset($urlParams['page'])) { $key .= '_p' . (int) $urlParams['page']; } if (isset($request->three_o_four_cache_opts['evaluate_params'])) { foreach ($request->three_o_four_cache_opts['evaluate_params'] as $k => $v) { if (isset($urlParams[$v])) { $key .= '_' . $k . $request->urlParams[$v]; } } } return $key; }
function place_order() { $billing_add = $this->session->userdata('billing_add'); $shipping_add = $this->session->userdata('shipping_add'); $billingAdd = $this->user_model->getAddress($billing_add); $shippingAdd = $this->user_model->getAddress($shipping_add); $data['shippingAdd'] = $shippingAdd; $data['billingAdd'] = $billingAdd; $data['cartDetails'] = $this->cart->contents(); $orderDetails['ord_id'] = rand(0, 99999999); $orderDetails['ord_user_id'] = get_logged_user('id'); $orderDetails['ord_shipping_id'] = $shipping_add; $orderDetails['ord_billing_id'] = $billing_add; $orderDetails['ord_status'] = 1; $data['orderId'] = $orderDetails['ord_id']; $this->user_model->addNewOrder($orderDetails, $this->cart->contents()); $mesage = $this->load->view('cart/order_template', $data, true); /* Mail to user */ $this->load->library('email'); $config['charset'] = 'iso-8859-1'; $config['wordwrap'] = TRUE; $config['mailtype'] = 'html'; $this->email->initialize($config); $this->email->from(MAILID_CHECKOUT, MAIL_FROM_NAME); $this->email->to(get_logged_user('email')); $this->email->reply_to('*****@*****.**'); $this->email->subject('Your Cart!'); $this->email->message($mesage); $this->email->send(); /* Mail to admin */ $this->load->library('email'); $config['charset'] = 'iso-8859-1'; $config['wordwrap'] = TRUE; $config['mailtype'] = 'html'; $this->email->initialize($config); $this->email->from(MAILID_CHECKOUT, MAIL_FROM_NAME); $this->email->to(MAILID_CHECKOUT); $this->email->reply_to('*****@*****.**'); $this->email->subject('Products Purchased'); $this->email->message($mesage); $this->email->send(); $this->cart->destroy(); $this->session->set_flashdata('app_success', 'Your cart successfully submitted!'); redirect('home'); }
function send_image_to_client($image_name, $file_alloweds = false) { // $model->screen_model->get_db(); $ci =& get_instance(); $session_user = unserialize(get_logged_user()); // dump($session_user); // dump($_FILES[$image_name]); $file_name = md5(date("d_m_Y_H_m_s_u")) . "_" . str_replace(" ", "_", stripAccents($_FILES[$image_name]['name'])); // $file_name = md5(date("Ymds")); $filename = $_FILES[$image_name]['tmp_name']; $handle = fopen($filename, "r"); $data = fread($handle, filesize($filename)); $POST_DATA = array('file' => base64_encode($data), 'name' => $file_name); $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $session_user->upload_path . "upload.php"); curl_setopt($curl, CURLOPT_TIMEOUT, 30); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $POST_DATA); curl_setopt($curl, CURLOPT_HEADER, true); $response = curl_exec($curl); $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); curl_close($curl); if ($httpCode != 200) { set_message("Erro ao publicar foto: <br/>" . $response, 2); } // dump($response); return $file_name; }