本文整理汇总了PHP中Localization::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Localization::instance方法的具体用法?PHP Localization::instance怎么用?PHP Localization::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Localization
的用法示例。
在下文中一共展示了Localization::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: lang
/**
* Shortcut function for retrieving single lang value
*
* @access public
* @param string $name
* @return string
*/
function lang($name)
{
// Get function arguments and remove first one.
$args = func_get_args();
if (is_array($args)) {
array_shift($args);
}
// if
// Get value and if we have NULL done!
if (plugin_active('i18n')) {
$value = lang_from_db($name);
} else {
$value = Localization::instance()->lang($name);
}
if (is_null($value)) {
return $value;
}
// if
// We have args? Replace all %s with arguments
if (is_array($args) && count($args)) {
foreach ($args as $arg) {
$value = str_replace_first('%s', $arg, $value);
}
// foreach
}
// if
// Done here...
return $value;
}
示例2: langA
function langA($name, $args)
{
static $base = null;
$value = Localization::instance()->lang($name);
if (is_null($value)) {
if (!Env::isDebugging()) {
if (!$base instanceof Localization) {
$base = new Localization();
$base->loadSettings("en_us", ROOT . "/language");
}
$value = $base->lang($name);
}
if (is_null($value)) {
$value = Localization::instance()->lang(str_replace(" ", "_", $name));
if (is_null($value)) {
$value = Localization::instance()->lang(str_replace("_", " ", $name));
if (is_null($value)) {
return "Missing lang: {$name}";
}
}
}
}
// We have args? Replace all {x} with arguments
if (is_array($args) && count($args)) {
$i = 0;
foreach ($args as $arg) {
$value = str_replace('{' . $i . '}', $arg, $value);
$i++;
}
// foreach
}
// if
// Done here...
return $value;
}
示例3: getInstance
public static function getInstance()
{
if (!isset(self::$instance)) {
$class = __CLASS__;
self::$instance = new $class();
}
return self::$instance;
}
示例4: load_help
function load_help($template){
$dir = Localization::instance()->getLanguageDirPath().'/'.Localization::instance()->getLocale();
$help_file = $dir.'/help/'.$template.'.html';
if(is_file($help_file)){
return tpl_fetch($help_file);
}else{
$default = Localization::instance()->getLanguageDirPath().'/en_us/help/'.$template.'.html';
if(is_file($default)){
return tpl_fetch($default);
}else{
$noHelp = Localization::instance()->getLanguageDirPath().'/en_us/help/no_help.html';
if(is_file($noHelp)){
return tpl_fetch($noHelp);
}else{
return '';
}
}
}
}
示例5: create_user
function create_user($user_data, $permissionsString)
{
$user = new User();
$user->setUsername(array_var($user_data, 'username'));
$user->setDisplayName(array_var($user_data, 'display_name'));
$user->setEmail(array_var($user_data, 'email'));
$user->setCompanyId(array_var($user_data, 'company_id'));
$user->setType(array_var($user_data, 'type'));
$user->setTimezone(array_var($user_data, 'timezone'));
if (!logged_user() instanceof User || can_manage_security(logged_user())) {
$user->setCanEditCompanyData(array_var($user_data, 'can_edit_company_data'));
$user->setCanManageSecurity(array_var($user_data, 'can_manage_security'));
$user->setCanManageWorkspaces(array_var($user_data, 'can_manage_workspaces'));
$user->setCanManageConfiguration(array_var($user_data, 'can_manage_configuration'));
$user->setCanManageContacts(array_var($user_data, 'can_manage_contacts'));
$user->setCanManageTemplates(array_var($user_data, 'can_manage_templates'));
$user->setCanManageReports(array_var($user_data, 'can_manage_reports'));
$user->setCanManageTime(array_var($user_data, 'can_manage_time'));
$user->setCanAddMailAccounts(array_var($user_data, 'can_add_mail_accounts'));
$other_permissions = array();
Hook::fire('add_user_permissions', $user, $other_permissions);
foreach ($other_permissions as $k => $v) {
$user->setColumnValue($k, array_var($user_data, $k));
}
}
if (array_var($user_data, 'password_generator', 'random') == 'random') {
// Generate random password
$password = UserPasswords::generateRandomPassword();
} else {
// Validate input
$password = array_var($user_data, 'password');
if (trim($password) == '') {
throw new Error(lang('password value required'));
}
// if
if ($password != array_var($user_data, 'password_a')) {
throw new Error(lang('passwords dont match'));
}
// if
}
// if
$user->setPassword($password);
$user->save();
$user_password = new UserPassword();
$user_password->setUserId($user->getId());
$user_password->setPasswordDate(DateTimeValueLib::now());
$user_password->setPassword(cp_encrypt($password, $user_password->getPasswordDate()->getTimestamp()));
$user_password->password_temp = $password;
$user_password->save();
if (array_var($user_data, 'autodetect_time_zone', 1) == 1) {
set_user_config_option('autodetect_time_zone', 1, $user->getId());
}
if ($user->getType() == 'admin') {
if ($user->getCompanyId() != owner_company()->getId() || logged_user() instanceof User && !can_manage_security(logged_user())) {
// external users can't be admins or logged user has no rights to create admins => set as Normal
$user->setType('normal');
} else {
$user->setAsAdministrator(true);
}
}
/* create contact for this user*/
if (array_var($user_data, 'create_contact', 1)) {
// if contact with same email exists take it, else create new
$contact = Contacts::getByEmail($user->getEmail(), true);
if (!$contact instanceof Contact) {
$contact = new Contact();
$contact->setEmail($user->getEmail());
} else {
if ($contact->isTrashed()) {
$contact->untrash();
}
}
$contact->setFirstname($user->getDisplayName());
$contact->setUserId($user->getId());
$contact->setTimezone($user->getTimezone());
$contact->setCompanyId($user->getCompanyId());
$contact->save();
} else {
$contact_id = array_var($user_data, 'contact_id');
$contact = Contacts::findById($contact_id);
if ($contact instanceof Contact) {
// user created from a contact
$contact->setUserId($user->getId());
$contact->save();
} else {
// if contact with same email exists use it as user's contact, without changing it
$contact = Contacts::getByEmail($user->getEmail(), true);
if ($contact instanceof Contact) {
$contact->setUserId($user->getId());
if ($contact->isTrashed()) {
$contact->untrash();
}
$contact->save();
}
}
}
$contact = $user->getContact();
if ($contact instanceof Contact) {
// update contact data with data entered for this user
$contact->setCompanyId($user->getCompanyId());
//.........这里部分代码省略.........
示例6: executeReport
/**
* Execute a report and return results
*
* @param $id
* @param $params
*
* @return array
*/
static function executeReport($id, $params, $order_by_col = '', $order_by_asc = true, $offset = 0, $limit = 50, $to_print = false)
{
if (is_null(active_context())) {
CompanyWebsite::instance()->setContext(build_context_array(array_var($_REQUEST, 'context')));
}
$results = array();
$report = self::getReport($id);
$show_archived = false;
if ($report instanceof Report) {
$conditionsFields = ReportConditions::getAllReportConditionsForFields($id);
$conditionsCp = ReportConditions::getAllReportConditionsForCustomProperties($id);
$ot = ObjectTypes::findById($report->getReportObjectTypeId());
$table = $ot->getTableName();
if ($ot->getType() == 'dimension_object' || $ot->getType() == 'dimension_group') {
$hook_parameters = array('report' => $report, 'params' => $params, 'order_by_col' => $order_by_col, 'order_by_asc' => $order_by_asc, 'offset' => $offset, 'limit' => $limit, 'to_print' => $to_print);
$report_result = null;
Hook::fire('replace_execute_report_function', $hook_parameters, $report_result);
if ($report_result) {
return $report_result;
}
}
eval('$managerInstance = ' . $ot->getHandlerClass() . "::instance();");
eval('$item_class = ' . $ot->getHandlerClass() . '::instance()->getItemClass(); $object = new $item_class();');
$order_by = '';
if (is_object($params)) {
$params = get_object_vars($params);
}
$report_columns = ReportColumns::getAllReportColumns($id);
$allConditions = "";
$contact_extra_columns = self::get_extra_contact_columns();
if (count($conditionsFields) > 0) {
foreach ($conditionsFields as $condField) {
if ($condField->getFieldName() == "archived_on") {
$show_archived = true;
}
$skip_condition = false;
$model = $ot->getHandlerClass();
$model_instance = new $model();
$col_type = $model_instance->getColumnType($condField->getFieldName());
$allConditions .= ' AND ';
$dateFormat = 'm/d/Y';
if (isset($params[$condField->getId()])) {
$value = $params[$condField->getId()];
if ($col_type == DATA_TYPE_DATE || $col_type == DATA_TYPE_DATETIME) {
$dateFormat = user_config_option('date_format');
}
} else {
$value = $condField->getValue();
}
if ($ot->getHandlerClass() == 'Contacts' && in_array($condField->getFieldName(), $contact_extra_columns)) {
$allConditions .= self::get_extra_contact_column_condition($condField->getFieldName(), $condField->getCondition(), $value);
} else {
if ($value == '' && $condField->getIsParametrizable()) {
$skip_condition = true;
}
if (!$skip_condition) {
$field_name = $condField->getFieldName();
if (in_array($condField->getFieldName(), Objects::getColumns())) {
$field_name = 'o`.`' . $condField->getFieldName();
}
if ($condField->getCondition() == 'like' || $condField->getCondition() == 'not like') {
$value = '%' . $value . '%';
}
if ($col_type == DATA_TYPE_DATE || $col_type == DATA_TYPE_DATETIME) {
if ($value == date_format_tip($dateFormat)) {
$value = EMPTY_DATE;
} else {
$dtValue = DateTimeValueLib::dateFromFormatAndString($dateFormat, $value);
$value = $dtValue->format('Y-m-d');
}
}
if ($condField->getCondition() != '%') {
if ($col_type == DATA_TYPE_INTEGER || $col_type == DATA_TYPE_FLOAT) {
$allConditions .= '`' . $field_name . '` ' . $condField->getCondition() . ' ' . DB::escape($value);
} else {
if ($condField->getCondition() == '=' || $condField->getCondition() == '<=' || $condField->getCondition() == '>=') {
if ($col_type == DATA_TYPE_DATETIME || $col_type == DATA_TYPE_DATE) {
$equal = 'datediff(' . DB::escape($value) . ', `' . $field_name . '`)=0';
} else {
$equal = '`' . $field_name . '` ' . $condField->getCondition() . ' ' . DB::escape($value);
}
switch ($condField->getCondition()) {
case '=':
$allConditions .= $equal;
break;
case '<=':
case '>=':
$allConditions .= '(`' . $field_name . '` ' . $condField->getCondition() . ' ' . DB::escape($value) . ' OR ' . $equal . ') ';
break;
}
} else {
$allConditions .= '`' . $field_name . '` ' . $condField->getCondition() . ' ' . DB::escape($value);
//.........这里部分代码省略.........
示例7: session_start
session_start();
error_reporting(E_ALL);
if (function_exists('date_default_timezone_set')) {
date_default_timezone_set('GMT');
}
// if
define('UPGRADER_PATH', dirname(__FILE__));
// upgrader is here
define('INSTALLATION_PATH', realpath(UPGRADER_PATH . '/../../'));
// Feng Office installation that we need to upgrade is here
require UPGRADER_PATH . '/library/functions.php';
require UPGRADER_PATH . '/library/classes/ScriptUpgrader.class.php';
require UPGRADER_PATH . '/library/classes/ScriptUpgraderScript.class.php';
require UPGRADER_PATH . '/library/classes/ChecklistItem.class.php';
require UPGRADER_PATH . '/library/classes/Output.class.php';
require UPGRADER_PATH . '/library/classes/Output_Console.class.php';
require UPGRADER_PATH . '/library/classes/Output_Html.class.php';
require UPGRADER_PATH . '/library/classes/Localization.class.php';
require_once UPGRADER_PATH . '/library/classes/Template.class.php';
require_once INSTALLATION_PATH . '/config/config.php';
require_once INSTALLATION_PATH . '/environment/functions/general.php';
require_once INSTALLATION_PATH . '/environment/functions/files.php';
require_once INSTALLATION_PATH . '/environment/functions/utf.php';
require_once INSTALLATION_PATH . '/environment/classes/Error.class.php';
require_once INSTALLATION_PATH . '/environment/classes/errors/filesystem/FileDnxError.class.php';
require_once INSTALLATION_PATH . '/environment/classes/errors/filesystem/DirDnxError.class.php';
require_once INSTALLATION_PATH . '/environment/classes/container/IContainer.class.php';
require_once INSTALLATION_PATH . '/environment/classes/container/Container.class.php';
Localization::instance()->loadSettings(DEFAULT_LOCALIZATION, INSTALLATION_PATH . '/language');
// Set exception handler
set_exception_handler('dump_upgrader_exception');
示例8: trim
$colname = $context['column_name'];
//Check for custom properties
if (substr($colname, 0, 8) == 'property') {
$property_id = trim(substr($colname, 8));
if (is_numeric($property_id)) {
$prop = ObjectProperties::findById($property_id);
if ($prop instanceof ObjectProperty) {
echo $prop->getPropertyName();
} else {
break;
}
} else {
break;
}
} else {
if (Localization::instance()->lang_exists('field ' . $object->getObjectManagerName() . ' ' . $context['column_name'])) {
echo lang('field ' . $object->getObjectManagerName() . ' ' . $context['column_name']);
} else {
echo clean($context['column_name']);
}
}
?>
: </b>
<span class='desc'><?php
if ($object instanceof ProjectFileRevision) {
echo undo_htmlspecialchars($context['context']);
} else {
echo $context['context'];
}
?>
</span></td>
示例9: get_javascript_translation
function get_javascript_translation()
{
$content = "/* start */\n";
$fileDir = ROOT . "/language/" . Localization::instance()->getLocale();
//Get Feng Office translation files
$filenames = get_files($fileDir, "js");
sort($filenames);
foreach ($filenames as $f) {
$content .= "\n/* {$f} */\n";
$content .= "try {";
$content .= file_get_contents($f);
$content .= "} catch (e) {}";
}
$plugins = Plugins::instance()->getActive();
foreach ($plugins as $plugin) {
$plg_dir = $plugin->getLanguagePath() . "/" . Localization::instance()->getLocale();
if (is_dir($plg_dir)) {
$files = get_files($plg_dir, 'js');
if (is_array($files)) {
sort($files);
foreach ($files as $file) {
$content .= "\n/* {$file} */\n";
$content .= "try {";
/**
* The js file can contain PHP code so use include instead of file_get_contents.
* To avoid sending headers, use output buffer.
* This change help to avoid the need of multiple lang files.. javascripts and phps.
* You can create only one php file containing all traslations,
* and this will populate client and server side langs datasorces
*/
ob_start();
include $file;
$content .= ob_get_contents();
ob_end_clean();
//!important: Clean output buffer to save memory
$content .= "} catch (e) {}";
}
}
}
}
$content .= "\n/* end */\n";
$this->setLayout("json");
$this->renderText($content, true);
}
示例10: getDisplayDescription
/**
* Return display description
*
* @param void
* @return string
*/
function getDisplayDescription()
{
return Localization::instance()->lang('user ws config option desc ' . $this->getName(), '');
}
示例11: select_country_widget
/**
* Show select country box
*
* @access public
* @param string $name Control name
* @param string $value Country code of selected country
* @param array $attributes Array of additional select box attributes
* @return string
*/
function select_country_widget($name, $value, $attributes = null)
{
$country_codes = array_keys(CountryCodes::getAll());
$countries = array();
foreach ($country_codes as $code) {
if (Localization::instance()->lang_exists("country {$code}")) {
$countries[$code] = lang("country {$code}");
} else {
$countries[$code] = CountryCodes::getCountryNameByCode($code);
}
}
// foreach
asort($countries);
$country_options = array(option_tag(lang('none'), ''));
foreach ($countries as $country_code => $country_name) {
$option_attributes = $country_code == $value ? array('selected' => true) : null;
$country_options[] = option_tag($country_name, $country_code, $option_attributes);
}
// foreach
return select_box($name, $country_options, $attributes);
}
示例12: get_allowed_columns
private function get_allowed_columns($object_type)
{
$fields = array();
if (isset($object_type)) {
$customProperties = CustomProperties::getAllCustomPropertiesByObjectType($object_type);
$objectFields = array();
foreach ($customProperties as $cp) {
if ($cp->getType() == 'table') {
continue;
}
$fields[] = array('id' => $cp->getId(), 'name' => $cp->getName(), 'type' => $cp->getType(), 'values' => $cp->getValues(), 'multiple' => $cp->getIsMultipleValues());
}
$ot = ObjectTypes::findById($object_type);
eval('$managerInstance = ' . $ot->getHandlerClass() . "::instance();");
$objectColumns = $managerInstance->getColumns();
$objectFields = array();
$objectColumns = array_diff($objectColumns, $managerInstance->getSystemColumns());
foreach ($objectColumns as $column) {
$objectFields[$column] = $managerInstance->getColumnType($column);
}
$common_columns = Objects::instance()->getColumns(false);
$common_columns = array_diff_key($common_columns, array_flip($managerInstance->getSystemColumns()));
$objectFields = array_merge($objectFields, $common_columns);
foreach ($objectFields as $name => $type) {
if ($type == DATA_TYPE_FLOAT || $type == DATA_TYPE_INTEGER) {
$type = 'numeric';
} else {
if ($type == DATA_TYPE_STRING) {
$type = 'text';
} else {
if ($type == DATA_TYPE_BOOLEAN) {
$type = 'boolean';
} else {
if ($type == DATA_TYPE_DATE || $type == DATA_TYPE_DATETIME) {
$type = 'date';
}
}
}
}
$field_name = Localization::instance()->lang('field ' . $ot->getHandlerClass() . ' ' . $name);
if (is_null($field_name)) {
$field_name = lang('field Objects ' . $name);
}
$fields[] = array('id' => $name, 'name' => $field_name, 'type' => $type);
}
$externalFields = $managerInstance->getExternalColumns();
foreach ($externalFields as $extField) {
$field_name = Localization::instance()->lang('field ' . $ot->getHandlerClass() . ' ' . $extField);
if (is_null($field_name)) {
$field_name = lang('field Objects ' . $extField);
}
$fields[] = array('id' => $extField, 'name' => $field_name, 'type' => 'external', 'multiple' => 0);
}
//if Object type is person
$objType = ObjectTypes::findByName('contact');
if ($objType instanceof ObjectType) {
if ($object_type == $objType->getId()) {
$fields[] = array('id' => 'email_address', 'name' => lang('email address'), 'type' => 'text');
$fields[] = array('id' => 'phone_number', 'name' => lang('phone number'), 'type' => 'text');
$fields[] = array('id' => 'web_url', 'name' => lang('web pages'), 'type' => 'text');
$fields[] = array('id' => 'im_value', 'name' => lang('instant messengers'), 'type' => 'text');
$fields[] = array('id' => 'address', 'name' => lang('address'), 'type' => 'text');
}
}
}
usort($fields, array(&$this, 'compare_FieldName'));
return $fields;
}
示例13: checkbox_field
if ($cpv instanceof MemberCustomPropertyValue) {
$default_value = $cpv->getValue();
}
$name = 'member_custom_properties[' . $customProp->getId() . ']';
echo '<div style="margin-top:12px">';
if ($customProp->getType() == 'boolean') {
echo checkbox_field($name, $default_value, array('tabindex' => $startTi + $ti, 'style' => 'margin-right:4px', 'id' => $genid . 'cp' . $customProp->getId()));
}
$label = clean($customProp->getName());
if ($customProp->getIsSpecial()) {
$label = lang(str_replace("_special", "", $customProp->getCode()));
} else {
if ($customProp->getCode() != '') {
$tmp_label = Localization::instance()->lang($customProp->getCode());
if (is_null($tmp_label)) {
$tmp_label = Localization::instance()->lang(str_replace("_", " ", $customProp->getCode()));
}
if (!is_null($tmp_label) && $tmp_label != "") {
$label = $tmp_label;
}
}
}
echo label_tag($label, $genid . 'cp' . $customProp->getId(), $customProp->getIsRequired(), array('style' => 'display:inline'), $customProp->getType() == 'boolean' ? '' : ':');
echo '</div>';
switch ($customProp->getType()) {
case 'text':
case 'numeric':
case 'memo':
if ($customProp->getIsMultipleValues()) {
$numeric = $customProp->getType() == "numeric";
echo "<table><tr><td>";
示例14: workEstimate
function workEstimate(ProjectTask $task)
{
tpl_assign('task_assigned', $task);
if (!$task->getAssignedTo() instanceof Contact) {
return true;
// not assigned to user
}
if (!is_valid_email($task->getAssignedTo()->getEmailAddress())) {
return true;
}
$locale = $task->getAssignedTo()->getLocale();
Localization::instance()->loadSettings($locale, ROOT . '/language');
tpl_assign('title', $task->getObjectName());
tpl_assign('by', $task->getAssignedBy()->getObjectName());
tpl_assign('asigned', $task->getAssignedTo()->getObjectName());
$text = "";
if (config_option("wysiwyg_tasks")) {
$text = purify_html(nl2br($task->getDescription()));
} else {
$text = escape_html_whitespace($task->getDescription());
}
tpl_assign('description', $text);
//descripction
tpl_assign('description_title', lang("new task work estimate to you desc", $task->getObjectName(), $task->getCreatedBy()->getObjectName()));
//description_title
//priority
if ($task->getPriority()) {
if ($task->getPriority() >= ProjectTasks::PRIORITY_URGENT) {
$priorityColor = "#FF0000";
$priority = lang('urgent priority');
} else {
if ($task->getPriority() >= ProjectTasks::PRIORITY_HIGH) {
$priorityColor = "#FF9088";
$priority = lang('high priority');
} else {
if ($task->getPriority() <= ProjectTasks::PRIORITY_LOW) {
$priorityColor = "white";
$priority = lang('low priority');
} else {
$priorityColor = "#DAE3F0";
$priority = lang('normal priority');
}
}
}
tpl_assign('priority', array($priority, $priorityColor));
}
//context
$contexts = array();
if ($task->getMembersToDisplayPath()) {
$members = $task->getMembersToDisplayPath();
foreach ($members as $key => $member) {
$dim = Dimensions::getDimensionById($key);
if ($dim->getCode() == "customer_project") {
foreach ($members[$key] as $member) {
$obj_type = ObjectTypes::findById($member['ot']);
$contexts[$dim->getCode()][$obj_type->getName()][] = '<span style="' . get_workspace_css_properties($member['c']) . '">' . $member['name'] . '</span>';
}
} else {
foreach ($members[$key] as $member) {
$contexts[$dim->getCode()][] = '<span style="' . get_workspace_css_properties($member['c']) . '">' . $member['name'] . '</span>';
}
}
}
}
tpl_assign('contexts', $contexts);
//workspaces
//start date, due date or start
if ($task->getStartDate() instanceof DateTimeValue) {
$date = Localization::instance()->formatDescriptiveDate($task->getStartDate(), $task->getAssignedTo()->getTimezone());
$time = Localization::instance()->formatTime($task->getStartDate(), $task->getAssignedTo()->getTimezone());
if ($time > 0) {
$date .= " " . $time;
}
tpl_assign('start_date', $date);
//start_date
}
if ($task->getDueDate() instanceof DateTimeValue) {
$date = Localization::instance()->formatDescriptiveDate($task->getDueDate(), $task->getAssignedTo()->getTimezone());
$time = Localization::instance()->formatTime($task->getDueDate(), $task->getAssignedTo()->getTimezone());
if ($time > 0) {
$date .= " " . $time;
}
tpl_assign('due_date', $date);
//due_date
}
$attachments = array();
try {
$content = FileRepository::getBackend()->getFileContent(owner_company()->getPictureFile());
$file_path = ROOT . "/upload/logo_empresa.png";
$handle = fopen($file_path, 'wb');
fwrite($handle, $content);
fclose($handle);
if ($content != "") {
$attachments['logo'] = array('cid' => gen_id() . substr($task->getAssignedBy()->getEmailAddress(), strpos($task->getAssignedBy()->getEmailAddress(), '@')), 'path' => $file_path, 'type' => 'image/png', 'disposition' => 'inline', 'name' => 'logo_empresa.png');
tpl_assign('attachments', $attachments);
// attachments
}
} catch (FileNotInRepositoryError $e) {
// If no logo is set, don't interrupt notifications.
}
//.........这里部分代码省略.........
示例15: taskAssigned
/**
* Task has been assigned to the user
*
* @param ProjectTask $task
* @return boolean
* @throws NotifierConnectionError
*/
function taskAssigned(ProjectTask $task)
{
if ($task->isCompleted()) {
return true;
// task has been already completed...
}
// if
if (!$task->getAssignedTo() instanceof User) {
return true;
// not assigned to user
}
// if
/* Checks for assigned to user, to call SMS API */
if ($task->getAssignedTo() instanceof User) {
$user = $task->getAssignedTo();
$phone_num = Users::getPhoneNumberCustomProperty($user->getObjectId());
$sms_obj = new SmsController();
$sms_obj->prepareAssignSms($user->getDisplayName(), $task->getTitle(), get_class($task));
$sms_obj->sendSms($phone_num);
} else {
if ($task->getAssignedTo() instanceof Company) {
// Skipping implementation until business requirement is clear
}
}
// GET WS COLOR
$workspace_color = $task->getWorkspaceColorsCSV(logged_user()->getWorkspacesQuery());
tpl_assign('task_assigned', $task);
tpl_assign('workspace_color', $workspace_color);
$locale = $task->getAssignedTo()->getLocale();
Localization::instance()->loadSettings($locale, ROOT . '/language');
if ($task->getDueDate() instanceof DateTimeValue) {
$date = Localization::instance()->formatDescriptiveDate($task->getDueDate(), $task->getAssignedTo()->getTimezone());
tpl_assign('date', $date);
}
self::queueEmail(array(self::prepareEmailAddress($task->getAssignedTo()->getEmail(), $task->getAssignedTo()->getDisplayName())), self::prepareEmailAddress($task->getUpdatedBy()->getEmail(), $task->getUpdatedByDisplayName()), lang('task assigned to you', $task->getTitle(), $task->getProject() instanceof Project ? $task->getProject()->getName() : ''), tpl_fetch(get_template_path('task_assigned', 'notifier')));
// send
$locale = logged_user() instanceof User ? logged_user()->getLocale() : DEFAULT_LOCALIZATION;
Localization::instance()->loadSettings($locale, ROOT . '/language');
}