/** * Init company based on subdomain * * @access public * @param string * @return null * @throws Error */ private function initCompany() { $company = Contacts::getOwnerCompany(); if (!$company instanceof Contact) { throw new OwnerCompanyDnxError(); } $owner = null; if (GlobalCache::isAvailable()) { $owner = GlobalCache::get('owner_company_creator', $success); } if (!$owner instanceof Contact) { $owner = $company->getCreatedBy(); // Update cache if available if ($owner instanceof Contact && GlobalCache::isAvailable()) { GlobalCache::update('owner_company_creator', $owner); } } if (!$owner instanceof Contact) { throw new AdministratorDnxError(); } $this->setCompany($company); }
echo lang("loading"); ?> ... </div> <div id="subWsExpander" onmouseover="clearTimeout(og.eventTimeouts['swst']);" onmouseout="og.eventTimeouts['swst'] = setTimeout('og.HideSubWsTooltip()', 2000);" style="display:none;top:10px;"></div> <?php echo render_page_javascript(); echo render_page_inline_js(); $use_owner_company_logo = false; if (config_option('use_owner_company_logo_at_header') && owner_company()->hasLogo()) { $use_owner_company_logo = true; } if (GlobalCache::isAvailable()) { GlobalCache::update('check_for_popup_reminders_' . logged_user()->getId(), 1); } ?> <!-- header --> <div id="header"> <div id="headerContent"> <table class="headerLogoAndWorkspace"><tr><td style="width:60px"> <div id="logodiv" <?php echo $use_owner_company_logo ? 'style="background-image:url(' . owner_company()->getLogoUrl() . ');"' : ''; ?> ></div> </td><td> <div id="wsCrumbsWrapper"> <table><tr><td> <div id="wsCrumbsDiv"> <div style="font-size:150%;display:inline;">
/** * Set value * */ function setUserValue($new_value, $user_id = 0, $workspace_id = 0) { $val = null; if (GlobalCache::isAvailable()) { $val = GlobalCache::get('user_copt_val_' . $user_id . "_" . $this->getId(), $success); } if (!$val) { $val = UserWsConfigOptionValues::findById(array('option_id' => $this->getId(), 'user_id' => $user_id, 'workspace_id' => $workspace_id)); } if (!$val) { // if value was not found, create it $val = new UserWsConfigOptionValue(); $val->setOptionId($this->getId()); $val->setUserId($user_id); $val->setWorkspaceId($workspace_id); } $val->setValue($new_value); $val->save(); $this->updateUserValueCache($user_id, $workspace_id, $val->getValue()); if (GlobalCache::isAvailable()) { GlobalCache::update('user_copt_val_' . $user_id . "_" . $this->getId(), $val); } }
/** * Set value of specific user configuration option * * @param string $option_name * @param mixed $value * @param int $user_id User Id, if null logged user is taken * @return boolean */ function set_user_config_option($option_name, $value, $user_id = null ) { $config_option = ContactConfigOptions::getByName($option_name); if(!($config_option instanceof ContactConfigOption)) { return false; } $config_option->setContactValue($value, $user_id); // update cache if available if (GlobalCache::isAvailable()) { GlobalCache::update('user_config_option_'.$user_id.'_'.$option_name, $value); } return $config_option->save(); } // set_config_option
/** * Update default user preferences * */ function update_default_user_preferences() { $category = ContactConfigCategories::findById(get_id()); if (!$category instanceof ContactConfigCategory) { flash_error(lang('config category dnx')); $this->redirectToReferer(get_url('user', 'card')); } // if if ($category->isEmpty()) { flash_error(lang('config category is empty')); $this->redirectToReferer(get_url('user', 'card')); } // if $options = $category->getContactOptions(false); $categories = ContactConfigCategories::getAll(false); tpl_assign('category', $category); tpl_assign('options', $options); tpl_assign('config_categories', $categories); $submited_values = array_var($_POST, 'options'); if (is_array($submited_values)) { try { DB::beginWork(); foreach ($options as $option) { // update global cache if available if (GlobalCache::isAvailable()) { GlobalCache::delete('user_config_option_def_' . $option->getName()); } $new_value = array_var($submited_values, $option->getName()); if (is_null($new_value) || $new_value == $option->getValue()) { continue; } $option->setValue($new_value); $option->save(); if (!user_has_config_option($option->getName())) { evt_add('user preference changed', array('name' => $option->getName(), 'value' => $new_value)); } } // foreach DB::commit(); flash_success(lang('success update config value', $category->getDisplayName())); ajx_current("back"); } catch (Exception $ex) { DB::rollback(); flash_success(lang('error update config value', $category->getDisplayName())); } } // if }
function quick_config_filter_activity(){ $this->setLayout('empty'); $submited_values = array_var($_POST, 'filter'); $members = array_var($_GET, 'members'); tpl_assign('members', array_var($_GET, 'members')); $member_name = lang('view'); $obj_member = Members::findById($members); if($obj_member){ $type_obj = ObjectTypes::findById($obj_member->getObjectTypeId()); if($obj_member){ $member_name = lang($type_obj->getName()); } } tpl_assign('dim_name', $member_name); $filters_default = ContactConfigOptions::getFilterActivity(); $filters = ContactConfigOptionValues::getFilterActivityMember($filters_default->getId(),$members); if(!$filters){ $filters = ContactConfigOptions::getFilterActivity(); $filter_value = $filters->getDefaultValue(); tpl_assign('id', $filters->getId()); }else{ $filter_value = $filters->getValue(); tpl_assign('id', ''); } $filters_def = explode(",",$filter_value); // if($filters_def[0] == 1){ // tpl_assign('checked_dimension_yes', 'checked="checked"'); // }else{ // tpl_assign('checked_dimension_no', 'checked="checked"'); // } if($filters_def[1] == 1){ tpl_assign('timeslot', 'checked="checked"'); }else{ tpl_assign('timeslot', ''); } tpl_assign('show', $filters_def[2]); // if($filters_def[3] == 1){ // tpl_assign('checked_view_downloads_yes', 'checked="checked"'); // }else{ // tpl_assign('checked_view_downloads_no', 'checked="checked"'); // } if(is_array($submited_values)) { $members = array_var($submited_values,"members"); $new_value = array_var($submited_values,"dimension",0) . "," . array_var($submited_values,"timeslot",0) . "," . array_var($submited_values,"show",10). "," . array_var($submited_values,"view_downloads",0); $filters_default = ContactConfigOptions::getFilterActivity(); if(array_var($submited_values,"apply_everywhere") == 1){ $filters_default->setDefaultValue($new_value); $filters_default->save(); $filters = ContactConfigOptionValues::getFilterActivityDelete($filters_default->getId()); }else{ $filters = ContactConfigOptionValues::getFilterActivityMember($filters_default->getId(),$members); // update cache if available if (GlobalCache::isAvailable()) { GlobalCache::delete('user_config_option_'.logged_user()->getId().'_'.$filters_default->getName()."_".$members); } if(!$filters){ $filter_opt = new ContactConfigOptionValue(); $filter_opt->setOptionId($filters_default->getId()); $filter_opt->setContactId(logged_user()->getId()); $filter_opt->setValue($new_value); $filter_opt->setMemberId($members); $filter_opt->save(); }else{ $filters->setValue($new_value); $filters->save(); } evt_add("user preference changed", array('name' => $filters_default->getName()."_".$members, 'value' => $new_value)); } ajx_current("reload"); } }
/** * This function will use session ID from session or cookie and if presend log user * with that ID. If not it will simply break. * * When this function uses session ID from cookie the whole process will be treated * as new login and users last login time will be set to current time. * * @access public * @param void * @return boolean */ private function initLoggedUser() { $user_id = Cookie::getValue('id'); $twisted_token = Cookie::getValue('token'); $cn = Cookie::getValue('cn'); $remember = (bool) Cookie::getValue('remember', false); if (empty($user_id) || empty($twisted_token)) { return false; // we don't have a user } // if // check the cache if available $user = null; if (GlobalCache::isAvailable()) { $user = GlobalCache::get('logged_user_' . $user_id, $success); } if (!$user instanceof User) { $user = Users::findById($user_id); // Update cache if available if ($user instanceof User && GlobalCache::isAvailable()) { GlobalCache::update('logged_user_' . $user->getId(), $user); } } if (!$user instanceof User) { return false; // failed to find user } // if if (!$user->isValidToken($twisted_token)) { return false; // failed to validate token } // if if (!($cn == md5(array_var($_SERVER, 'REMOTE_ADDR', "")))) { return false; // failed to check ip address } // if $last_act = $user->getLastActivity(); if ($last_act) { $session_expires = $last_act->advance(SESSION_LIFETIME, false); } if (!$last_act || $session_expires != null && DateTimeValueLib::now()->getTimestamp() < $session_expires->getTimestamp()) { $this->setLoggedUser($user, $remember, true); } else { $this->logUserIn($user, $remember); } // if //$this->selected_project = $user->getPersonalProject(); }
/** * Save * */ function save() { if ($this->isNew()) { $max_users = config_option('max_users'); if ($max_users && Users::count() >= $max_users) { throw new Exception(lang("maximum number of users reached error")); } } parent::save(); // update logged_user info in global cache if (logged_user() instanceof User && $this->getId() == logged_user()->getId() && GlobalCache::isAvailable()) { GlobalCache::update('logged_user_' . $this->getId(), $this); } }
function quick_config_filter_activity() { $this->setLayout('empty'); $submited_values = array_var($_POST, 'filter'); $members = array_var($_GET, 'members'); tpl_assign('members', array_var($_GET, 'members')); $filters_default = ContactConfigOptions::getFilterActivity(); $filters = ContactConfigOptionValues::getFilterActivityMember($filters_default->getId(), $members); if (!$filters) { $filters = ContactConfigOptions::getFilterActivity(); $filter_value = $filters->getDefaultValue(); tpl_assign('id', $filters->getId()); } else { $filter_value = $filters->getValue(); } $filters_def = explode(",", $filter_value); if ($filters_def[0] == 1) { tpl_assign('checked_dimension_yes', 'checked="checked"'); } else { tpl_assign('checked_dimension_no', 'checked="checked"'); } if ($filters_def[1] == 1) { tpl_assign('checked_timeslot_yes', 'checked="checked"'); } else { tpl_assign('checked_timeslot_no', 'checked="checked"'); } tpl_assign('show', $filters_def[2]); if ($filters_def[3] == 1) { tpl_assign('checked_view_downloads_yes', 'checked="checked"'); } else { tpl_assign('checked_view_downloads_no', 'checked="checked"'); } if (is_array($submited_values)) { $members = array_var($submited_values, "members"); $filters_default = ContactConfigOptions::getFilterActivity(); $filters = ContactConfigOptionValues::getFilterActivityMember($filters_default->getId(), $members); // update cache if available if (GlobalCache::isAvailable()) { GlobalCache::delete('user_config_option_' . logged_user()->getId() . '_' . $filters_default->getName() . "_" . $members); } $new_value = array_var($submited_values, "dimension") . "," . array_var($submited_values, "timeslot") . "," . array_var($submited_values, "show") . "," . array_var($submited_values, "view_downloads"); if (!$filters) { $filter_opt = new ContactConfigOptionValue(); $filter_opt->setOptionId($filters_default->getId()); $filter_opt->setContactId(logged_user()->getId()); $filter_opt->setValue($new_value); $filter_opt->setMemberId($members); $filter_opt->save(); } else { $filters->setValue($new_value); $filters->save(); } evt_add("user preference changed", array('name' => $filters_default->getName() . "_" . $members, 'value' => $new_value)); redirect_to("index.php?c=dashboard&a=main_dashboard"); } }
function popup_reminders() { ajx_current("empty"); // extra data to send to interface $extra_data = array(); // if no new popup reminders don't make useless queries if (GlobalCache::isAvailable()) { $check = GlobalCache::get('check_for_popup_reminders_' . logged_user()->getId(), $success); if ($success && $check == 0) { return; } } $reminders = ObjectReminders::getDueReminders("reminder_popup"); $popups = array(); foreach ($reminders as $reminder) { $context = $reminder->getContext(); if (str_starts_with($context, "mails_in_outbox")) { if ($reminder->getUserId() > 0 && $reminder->getUserId() != logged_user()->getId()) { continue; } preg_match('!\\d+!', $context, $matches); evt_add("popup", array('title' => lang("mails_in_outbox reminder"), 'message' => lang("mails_in_outbox reminder desc", $matches[0]), 'type' => 'reminder', 'sound' => 'info')); $reminder->delete(); continue; } if (str_starts_with($context, "eauthfail")) { if ($reminder->getUserId() == logged_user()->getId()) { $acc = trim(substr($context, strrpos($context, " "))); evt_add("popup", array('title' => lang("failed to authenticate email account"), 'message' => lang("failed to authenticate email account desc", $acc), 'type' => 'reminder', 'sound' => 'info')); $reminder->delete(); } continue; } $object = $reminder->getObject(); $type = $object->getObjectTypeName(); $date = $object->getColumnValue($reminder->getContext()); if (!$date instanceof DateTimeValue) { continue; } if ($object->isTrashed()) { $reminder->delete(); continue; } // convert time to the user's locale $timezone = logged_user()->getTimezone(); if ($date->getTimestamp() + 5 * 60 < DateTimeValueLib::now()->getTimestamp()) { // don't show popups older than 5 minutes //$reminder->delete(); //continue; } if ($reminder->getUserId() == 0) { if (!$object->isSubscriber(logged_user())) { // reminder for subscribers and user is not subscriber continue; } } else { if ($reminder->getUserId() != logged_user()->getId()) { continue; } } if ($context == "due_date" && $object instanceof ProjectTask) { if ($object->isCompleted()) { // don't show popups for completed tasks $reminder->delete(); continue; } } $url = $object->getViewUrl(); $link = '<a href="#" onclick="og.openLink(\'' . $url . '\');return false;">' . clean($object->getObjectName()) . '</a>'; evt_add("popup", array('title' => lang("{$context} {$type} reminder", clean($object->getObjectName())), 'message' => lang("{$context} {$type} reminder desc", $link, format_datetime($date)), 'type' => 'reminder', 'sound' => 'info')); if ($reminder->getUserId() == 0) { // reminder is for all subscribers, so change it for one reminder per user (except logged_user) // otherwise if deleted it won't notify other subscribers and if not deleted it will keep notifying // logged user $subscribers = $object->getSubscribers(); foreach ($subscribers as $subscriber) { if ($subscriber->getId() != logged_user()->getId()) { $new = new ObjectReminder(); $new->setContext($reminder->getContext()); $new->setDate($reminder->getDate()); $new->setMinutesBefore($reminder->getMinutesBefore()); $new->setObject($object); $new->setUser($subscriber); $new->setType($reminder->getType()); $new->save(); } } } $reminder->delete(); } // popup reminders already checked for logged user if (GlobalCache::isAvailable()) { $today_next_reminders = ObjectReminders::findAll(array('conditions' => array("`date` > ? AND `date` < ?", DateTimeValueLib::now(), DateTimeValueLib::now()->endOfDay()), 'limit' => config_option('cron reminder limit', 100))); if (count($today_next_reminders) == 0) { GlobalCache::update('check_for_popup_reminders_' . logged_user()->getId(), 0, 60 * 30); } } // check for member modifications if (isset($_POST['dims_check_date'])) { $dims_check_date = new DateTimeValue($_POST['dims_check_date']); $dims_check_date_sql = $dims_check_date->toMySQL(); $members_log_count = ApplicationLogs::instance()->count("member_id>0 AND created_on>'{$dims_check_date_sql}'"); if ($members_log_count > 0) { $extra_data['reload_dims'] = 1; } } ajx_extra_data($extra_data); }
public function getMultiCache($keys = array()) { $result = GlobalCache::getMultiCache($keys, $this->_cache_instance); }
/** * Edit client * * @param void * @return null */ function edit_client() { if (logged_user()->isGuest()) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } $this->setTemplate('add_company'); $company = Companies::findById(get_id()); if (!$company->canEdit(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } // if if (!$company instanceof Company) { flash_error(lang('client dnx')); ajx_current("empty"); return; } // if $company_data = array_var($_POST, 'company'); if (!is_array($company_data)) { $tag_names = $company->getTagNames(); $company_data = array('name' => $company->getName(), 'tags' => is_array($tag_names) ? implode(', ', $tag_names) : '', 'timezone' => $company->getTimezone(), 'email' => $company->getEmail(), 'homepage' => $company->getHomepage(), 'address' => $company->getAddress(), 'address2' => $company->getAddress2(), 'city' => $company->getCity(), 'state' => $company->getState(), 'zipcode' => $company->getZipcode(), 'country' => $company->getCountry(), 'phone_number' => $company->getPhoneNumber(), 'fax_number' => $company->getFaxNumber(), 'notes' => $company->getNotes()); // array } // if tpl_assign('company', $company); tpl_assign('company_data', $company_data); if (is_array(array_var($_POST, 'company'))) { $company->setFromAttributes($company_data); $is_owner_company = false; if (owner_company()->getId() == $company->getId()) { $company->setClientOfId(0); $is_owner_company = true; } else { $company->setClientOfId(owner_company()->getId()); } $company->setHomepage(array_var($company_data, 'homepage')); try { DB::beginWork(); $company->save(); $company->setTagsFromCSV(array_var($company_data, 'tags')); $object_controller = new ObjectController(); $object_controller->add_to_workspaces($company, !can_manage_contacts(logged_user())); $object_controller->link_to_new_object($company); $object_controller->add_subscribers($company); $object_controller->add_custom_properties($company); ApplicationLogs::createLog($company, $company->getWorkspaces(), ApplicationLogs::ACTION_EDIT); DB::commit(); // Update global cache if ($is_owner_company && GlobalCache::isAvailable()) { GlobalCache::update('owner_company', $company); } flash_success(lang('success edit client', $company->getName())); ajx_current("back"); } catch (Exception $e) { DB::rollback(); ajx_current("empty"); flash_error($e->getMessage()); } // try } // if }
/** * Set value of specific user configuration option * * @param string $option_name * @param mixed $value * @param int $user_id User Id, if null logged user is taken * @return boolean */ function set_user_config_option($option_name, $value, $user_id = null) { $config_option = UserWsConfigOptions::getByName($option_name); if (!$config_option instanceof UserWsConfigOption) { return false; } // if $config_option->setUserValue($value, $user_id); // update cache if available if (GlobalCache::isAvailable() && GlobalCache::key_exists('user_config_option_' . $user_id . '_' . $option_name)) { GlobalCache::update('user_config_option_' . $user_id . '_' . $option_name, $value); } return $config_option->save(); }
private function unsetGlobal() { Globals::closeAllDbConnection(); GlobalCache::flushLocalCache("default"); GlobalCache::flushLocalCache("profile"); }
function scolors() { if (can_manage_configuration(logged_user())) { $colors = array_var($_POST, 'colors'); $owner_company = owner_company(); $owner_company->setBrandColors($colors); $owner_company->save(); if (GlobalCache::isAvailable()) { GlobalCache::update('owner_company', $owner_company); } } exit; }
/** * Contruct controller and execute specific action * * @access public * @param string $controller_name * @param string $action * @return null */ static function executeAction($controller_name, $action) { $max_users = config_option('max_users'); if ($max_users && Users::count() > $max_users) { echo lang("error") . ": " . lang("maximum number of users exceeded error"); return; } ajx_check_login(); if (isset($_GET['active_project']) && logged_user() instanceof User) { $dont_update = false; if (GlobalCache::isAvailable()) { $option_value = GlobalCache::get('user_config_option_' . logged_user()->getId() . '_lastAccessedWorkspace', $success); if ($success) { $dont_update = $option_value == $_GET['active_project']; } } if (!$dont_update) { set_user_config_option('lastAccessedWorkspace', $_GET['active_project'], logged_user()->getId()); if (GlobalCache::isAvailable()) { GlobalCache::update('user_config_option_' . logged_user()->getId() . '_lastAccessedWorkspace', $_GET['active_project']); } } } Env::useController($controller_name); $controller_class = Env::getControllerClass($controller_name); if (!class_exists($controller_class, false)) { throw new ControllerDnxError($controller_name); } // if $controller = new $controller_class(); if (!instance_of($controller, 'Controller')) { throw new ControllerDnxError($controller_name); } // if if (is_ajax_request()) { // if request is an ajax request return a json response // execute the action $controller->setAutoRender(false); $controller->execute($action); // fill the response $response = AjaxResponse::instance(); if (!$response->hasCurrent()) { // set the current content $response->setCurrentContent("html", $controller->getContent(), page_actions(), ajx_get_panel()); } $response->setEvents(evt_pop()); $error = flash_pop('error'); $success = flash_pop('success'); if (!is_null($error)) { $response->setError(1, clean($error)); } else { if (!is_null($success)) { $response->setError(0, clean($success)); } } // display the object as json tpl_assign("object", $response); $content = tpl_fetch(Env::getTemplatePath("json")); tpl_assign("content_for_layout", $content); TimeIt::start("Transfer"); if (is_iframe_request()) { tpl_display(Env::getLayoutPath("iframe")); } else { tpl_display(Env::getLayoutPath("json")); } TimeIt::stop(); } else { return $controller->execute($action); } }
function popup_reminders() { ajx_current("empty"); // if no new popup reminders don't make useless queries if (GlobalCache::isAvailable()) { $check = GlobalCache::get('check_for_popup_reminders_' . logged_user()->getId(), $success); if ($success && $check == 0) { return; } } $reminders = ObjectReminders::getDueReminders("reminder_popup"); $popups = array(); foreach ($reminders as $reminder) { $object = $reminder->getObject(); $context = $reminder->getContext(); $type = $object->getObjectTypeName(); $date = $object->getColumnValue($reminder->getContext()); if (!$date instanceof DateTimeValue) { continue; } if ($object->isTrashed()) { $reminder->delete(); continue; } // convert time to the user's locale $timezone = logged_user()->getTimezone(); if ($date->getTimestamp() + 5 * 60 < DateTimeValueLib::now()->getTimestamp()) { // don't show popups older than 5 minutes $reminder->delete(); continue; } if ($reminder->getUserId() == 0) { if (!$object->isSubscriber(logged_user())) { // reminder for subscribers and user is not subscriber continue; } } else { if ($reminder->getUserId() != logged_user()->getId()) { continue; } } if ($context == "due_date" && $object instanceof ProjectTask) { if ($object->isCompleted()) { // don't show popups for completed tasks $reminder->delete(); continue; } } $url = $object->getViewUrl(); $link = '<a href="#" onclick="og.openLink(\'' . $url . '\');return false;">' . clean($object->getObjectName()) . '</a>'; evt_add("popup", array('title' => lang("{$context} {$type} reminder"), 'message' => lang("{$context} {$type} reminder desc", $link, format_datetime($date)), 'type' => 'reminder', 'sound' => 'info')); if ($reminder->getUserId() == 0) { // reminder is for all subscribers, so change it for one reminder per user (except logged_user) // otherwise if deleted it won't notify other subscribers and if not deleted it will keep notifying // logged user $subscribers = $object->getSubscribers(); foreach ($subscribers as $subscriber) { if ($subscriber->getId() != logged_user()->getId()) { $new = new ObjectReminder(); $new->setContext($reminder->getContext()); $new->setDate($reminder->getDate()); $new->setMinutesBefore($reminder->getMinutesBefore()); $new->setObject($object); $new->setUser($subscriber); $new->setType($reminder->getType()); $new->save(); } } } $reminder->delete(); } // popup reminders already checked for logged user if (GlobalCache::isAvailable()) { $today_next_reminders = ObjectReminders::findAll(array('conditions' => array("`date` > ? AND `date` < ?", DateTimeValueLib::now(), DateTimeValueLib::now()->endOfDay()), 'limit' => config_option('cron reminder limit', 100))); if (count($today_next_reminders) == 0) { GlobalCache::update('check_for_popup_reminders_' . logged_user()->getId(), 0, 60 * 30); } } }
/** * Return owner company * * @access public * @param void * @return Company */ static function getOwnerCompany() { $owner_company = null; if (GlobalCache::isAvailable()) { $owner_company = GlobalCache::get('owner_company', $success); if ($success && $owner_company instanceof Contact) { return $owner_company; } } $owner_company = Contacts::findOne(array("conditions" => " is_company > 0", "limit" => 1, "order" => "object_id ASC")); if (GlobalCache::isAvailable()) { GlobalCache::update('owner_company', $owner_company); } return $owner_company; }
/** * Return config option by name * * @access public * @param string $name * @return ContactConfigOption */ static function getByName($name) { if (GlobalCache::isAvailable()) { $object = GlobalCache::get('user_copt_obj_' . $name, $success); if ($success) { return $object; } } $object = self::findOne(array('conditions' => array('`name` = ?', $name))); if (GlobalCache::isAvailable()) { GlobalCache::update('user_copt_obj_' . $name, $object); } return $object; }
/** * Return owner company * * @access public * @param void * @return Company */ static function getOwnerCompany() { $owner_company = null; if (GlobalCache::isAvailable()) { $owner_company = GlobalCache::get('owner_company', $success); if ($success && $owner_company instanceof Company) { return $owner_company; } } $owner_company = Companies::findOne(array('conditions' => array('`client_of_id` = ?', 0), 'include_trashed' => true)); // findOne if (GlobalCache::isAvailable()) { GlobalCache::update('owner_company', $owner_company); } return $owner_company; }