Inheritance: extends DBTable
Example #1
0
 public function reminder($id_user)
 {
     $i = 0;
     if (Zend_Registry::isRegistered('Zend_Translate')) {
         $translator = Zend_Registry::get('Zend_Translate');
     }
     if (!$id_user || $id_user == null) {
         $modelReminder = new Reminder();
         $dataReminders = $modelReminder->fetchToSendEmailAll();
     } elseif ($id_user) {
         $modelReminder = new Reminder();
         $dataReminders = $modelReminder->fetchToSendEmail($id_user);
     }
     foreach ($dataReminders as $dataReminder) {
         $modelUser = new User();
         $dataUsers = $modelUser->findOne($dataReminder['created_by']);
         $userEmail = $dataUser['email'];
         $this->view->description = str_replace("ó", "ó", strip_tags($dataReminder['description']));
         $body = $this->view->render('/_mail/reminder.phtml');
         $client = new Logic_MailerAdapter();
         $client->mail($userEmail, $translator->translate('Reminder') . ' - ' . $dataReminder['title'], array('type' => 1, 'content' => $body));
         $modelReminder->setAsSent($dataReminder['id']);
         $i++;
     }
     return $i;
 }
Example #2
0
function OpportunitiesReminder()
{
    $GLOBALS['log']->info('----->Scheduler fired job of type sendEmailReminders()');
    require_once "custom/modules/Opportunities/Reminder.php";
    $reminder = new Reminder();
    return $reminder->process();
}
 function getReservations($userid, $start, $end)
 {
     $return = array();
     $values = array($userid, $userid);
     $query = 'SELECT r.*, rem.reminder_time, rem.reminderid, ru.* FROM ' . $this->get_table(TBL_RESERVATIONS) . ' r' . ' INNER JOIN ' . $this->get_table(TBL_RESERVATION_USERS) . ' ru ON r.resid = ru.resid' . ' LEFT JOIN ' . $this->get_table(TBL_REMINDERS) . ' rem ON r.resid = rem.resid AND rem.memberid = ?' . ' WHERE ru.memberid = ? AND ru.invited = 0';
     if ($start != null) {
         $values[] = $start->date;
         $values[] = $start->date;
         $values[] = $start->time;
         $query .= ' AND (r.start_date >= ? OR (r.start_date = ? AND r.starttime >= ?))';
     }
     if ($end != null) {
         $values[] = $end->date;
         $values[] = $end->date;
         $values[] = $end->time;
         $query .= ' AND (r.end_date <= ? OR (r.end_date = ? AND r.endtime <= ?))';
     }
     $result = $this->db->query($query, $values);
     $this->check_for_error($result);
     while ($rs = $result->fetchRow()) {
         $res = new ReservationResult();
         $res->id = $rs['resid'];
         $res->start_date = $rs['start_date'];
         $res->end_date = $rs['end_date'];
         $res->start = $rs['starttime'];
         $res->end = $rs['endtime'];
         $res->resource = new Resource($rs['machid']);
         $res->resource->db = null;
         $res->created = $rs['created'];
         $res->modified = $rs['modified'];
         $res->parentid = $rs['parentid'];
         $res->summary = $rs['summary'];
         $res->scheduleid = $rs['scheduleid'];
         $res->is_pending = $rs['is_pending'];
         $res->is_participant = $rs['owner'] == 0;
         $reminder = new Reminder($rs['reminderid']);
         $reminder->set_reminder_time($rs['reminder_time']);
         $res->reminderid = $rs['reminderid'];
         $res->reminder_minutes_prior = $reminder->getMinutuesPrior($res);
         $users = $this->get_res_users($res->id);
         for ($i = 0; $i < count($users); $i++) {
             if ($users[$i]['owner'] == 1) {
                 $res->user = new User($users[$i]['memberid']);
                 $res->user->db = null;
                 break;
             } else {
                 $res->users[] = $users[$i];
             }
         }
         $res->resources = $this->get_sup_resources($res->id);
         $return[] = $res;
     }
     $result->free();
     return $return;
 }
Example #4
0
 public static function createFrom($when)
 {
     $new_reminder = new Reminder();
     if (is_array($when)) {
         // Related to start/end
         $new_reminder->is_absolute = FALSE;
         $new_reminder->parse_trigger($when);
     } else {
         // Absolute
         $new_reminder->is_absolute = TRUE;
         $new_reminder->absdatetime = $when;
     }
     return $new_reminder;
 }
Example #5
0
 protected function takeChildFromDOM($child)
 {
     $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
     switch ($absoluteNodeName) {
         case $this->lookupNamespace('gd') . ':' . 'reminder':
             $reminder = new Reminder();
             $reminder->transferFromDOM($child);
             $this->_reminders[] = $reminder;
             break;
         default:
             parent::takeChildFromDOM($child);
             break;
     }
 }
Example #6
0
 /**
  * [saveModel]
  * @param  boolean $reminder [description]
  * @return [type]            [description]
  */
 protected function saveModel($reminder = false)
 {
     if (Input::get('id')) {
         $reminder = Reminder::find(Input::get('id'));
     }
     if (!$reminder) {
         $reminder = new Reminder();
     }
     //$load_company_model = $project->company;
     $reminder->project_id = Input::get('project_id');
     $reminder->user_id = Input::get('user_id');
     $reminder->description = Input::get('description');
     $reminder->save();
     return $reminder;
 }
 /**
  * Dismiss reminder
  *
  * @param void
  * @return null
  */
 function dismiss()
 {
     if ($this->active_reminder->isNew()) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     if (!$this->active_reminder->canDismiss($this->logged_user)) {
         $this->httpError(HTTP_ERR_FORBIDDEN);
     }
     // if
     if ($this->request->isSubmitted()) {
         if ($this->active_reminder->delete()) {
             if ($this->request->isAsyncCall()) {
                 $this->httpOk();
             } else {
                 flash_success('Selected reminder has been dismissed');
             }
             // if
         } else {
             if ($this->request->isAsyncCall()) {
                 $this->httpError(HTTP_ERR_OPERATION_FAILED);
             } else {
                 flash_error('Failed to dismiss selected reminder');
             }
             // if
         }
         // if
         $this->redirectToReferer(assemble_url('homepage'));
     } else {
         $this->httpError(HTTP_ERR_BAD_REQUEST);
     }
     // if
 }
Example #8
0
 public static function IsCandidate(User $user, $candidate)
 {
     $profile = $user->profile();
     if (!$profile) {
         return false;
     }
     // We only test if the user is in her promotion group for it is too
     // expensive to check if she is in the corresponding ML as well.
     $res = XDB::query('SELECT  COUNT(*)
                          FROM  group_members
                         WHERE  uid = {?} AND asso_id = (SELECT  id
                                                           FROM  groups
                                                          WHERE  diminutif = {?})', $user->id(), $user->profile()->yearPromo());
     $mlCount = $res->fetchOneCell();
     if ($mlCount) {
         Reminder::MarkCandidateAsAccepted($user->id(), $candidate);
     }
     if ($mlCount == 0) {
         $mlist = MailingList::promo($user->profile()->yearPromo());
         try {
             $mlist->getMembersLimit(0, 0);
         } catch (Exception $e) {
             return false;
         }
     }
     return false;
 }
Example #9
0
 /**
  * Adds an email to the outgoing mail queue.
  *
  * @param   string $recipient The recipient of this email
  * @param   array $headers The list of headers that should be sent with this email
  * @param   string $body The body of the message
  * @param   integer $save_email_copy Whether to send a copy of this email to a configurable address or not (eventum_sent@)
  * @param   integer $issue_id The ID of the issue. If false, email will not be associated with issue.
  * @param   string $type The type of message this is.
  * @param   integer $sender_usr_id The id of the user sending this email.
  * @param   integer $type_id The ID of the event that triggered this notification (issue_id, sup_id, not_id, etc)
  * @return  true, or a PEAR_Error object
  */
 public static function add($recipient, $headers, $body, $save_email_copy = 0, $issue_id = false, $type = '', $sender_usr_id = false, $type_id = false)
 {
     Workflow::modifyMailQueue(Auth::getCurrentProject(false), $recipient, $headers, $body, $issue_id, $type, $sender_usr_id, $type_id);
     // avoid sending emails out to users with inactive status
     $recipient_email = Mail_Helper::getEmailAddress($recipient);
     $usr_id = User::getUserIDByEmail($recipient_email);
     if (!empty($usr_id)) {
         $user_status = User::getStatusByEmail($recipient_email);
         // if user is not set to an active status, then silently ignore
         if (!User::isActiveStatus($user_status) && !User::isPendingStatus($user_status)) {
             return false;
         }
     }
     $to_usr_id = User::getUserIDByEmail($recipient_email);
     $recipient = Mail_Helper::fixAddressQuoting($recipient);
     $reminder_addresses = Reminder::_getReminderAlertAddresses();
     // add specialized headers
     if (!empty($issue_id) && (!empty($to_usr_id) && User::getRoleByUser($to_usr_id, Issue::getProjectID($issue_id)) != User::getRoleID('Customer')) || @in_array(Mail_Helper::getEmailAddress($recipient), $reminder_addresses)) {
         $headers += Mail_Helper::getSpecializedHeaders($issue_id, $type, $headers, $sender_usr_id);
     }
     // try to prevent triggering absence auto responders
     $headers['precedence'] = 'bulk';
     // the 'classic' way, works with e.g. the unix 'vacation' tool
     $headers['Auto-submitted'] = 'auto-generated';
     // the RFC 3834 way
     if (empty($issue_id)) {
         $issue_id = 'null';
     }
     // if the Date: header is missing, add it.
     if (empty($headers['Date'])) {
         $headers['Date'] = Mime_Helper::encode(date('D, j M Y H:i:s O'));
     }
     if (!empty($headers['To'])) {
         $headers['To'] = Mail_Helper::fixAddressQuoting($headers['To']);
     }
     // encode headers and add special mime headers
     $headers = Mime_Helper::encodeHeaders($headers);
     $res = Mail_Helper::prepareHeaders($headers);
     if (Misc::isError($res)) {
         Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
         return $res;
     }
     // convert array of headers into text headers
     list(, $text_headers) = $res;
     $params = array('maq_save_copy' => $save_email_copy, 'maq_queued_date' => Date_Helper::getCurrentDateGMT(), 'maq_sender_ip_address' => !empty($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '', 'maq_recipient' => $recipient, 'maq_headers' => $text_headers, 'maq_body' => $body, 'maq_iss_id' => $issue_id, 'maq_subject' => $headers['Subject'], 'maq_type' => $type);
     if ($sender_usr_id) {
         $params['maq_usr_id'] = $sender_usr_id;
     }
     if ($type_id) {
         $params['maq_type_id'] = $type_id;
     }
     $stmt = 'INSERT INTO {{%mail_queue}} SET ' . DB_Helper::buildSet($params);
     try {
         DB_Helper::getInstance()->query($stmt, $params);
     } catch (DbException $e) {
         return $res;
     }
     return true;
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $this->line('Cleaning activations and reminders tables from expired lines ...');
     \Activation::removeExpired();
     $this->info('✔ Activations table cleaned.');
     \Reminder::removeExpired();
     $this->info('✔ Reminders table cleaned.');
 }
Example #11
0
 public static function IsCandidate(User $user, $candidate)
 {
     $res = XDB::query("SELECT  COUNT(*) AS lists\n                             FROM  register_subs\n                            WHERE  uid = {?} AND type = 'list'", $user->id());
     $mlCount = $res->fetchOneCell();
     if (!$mlCount) {
         Reminder::MarkCandidateAsAccepted($user->id(), $candidate);
     }
     return $mlCount > 0;
 }
Example #12
0
 public static function IsCandidate(User $user, $candidate)
 {
     require_once 'newsletter.inc.php';
     $isSubscribed = NewsLetter::forGroup(NewsLetter::GROUP_AX)->subscriptionState();
     if ($isSubscribed) {
         Reminder::MarkCandidateAsAccepted($user->id(), $candidate);
     }
     return !$isSubscribed;
 }
Example #13
0
 /**
  * @param string $refnumber
  * @return Reminder[]
  */
 public function GetByRefNumber($refnumber)
 {
     $reminders = array();
     $reader = ServiceLocator::GetDatabase()->Query(new GetReminderByRefNumberCommand($refnumber));
     if ($row = $reader->GetRow()) {
         $reminders = Reminder::FromRow($row);
     }
     $reader->Free();
     return $reminders;
 }
Example #14
0
 public function Prepare($page)
 {
     parent::Prepare($page);
     $profile = $this->user->profile();
     $page->assign('profile_merge', self::ListMergeIssues($profile));
     $page->assign('profile_incitation', $profile->is_old);
     $page->assign('profile_last_update', $profile->last_change);
     $page->assign('photo_incitation', !$profile->has_photo);
     $page->assign('geocoding_incitation', Geocoder::countNonGeocoded($profile->id()));
 }
Example #15
0
 public static function IsCandidate(User $user, $candidate)
 {
     if (!$user->checkPerms(User::PERM_MAIL)) {
         return false;
     }
     require_once 'emails.inc.php';
     $active = Email::is_active_storage($user, 'imap');
     if ($active) {
         Reminder::MarkCandidateAsAccepted($user->id(), $candidate);
     }
     return !$active;
 }
Example #16
0
 public static function IsCandidate(User $user, $candidate)
 {
     if (!$user->checkPerms(User::PERM_MAIL)) {
         return false;
     }
     require_once 'googleapps.inc.php';
     $isSubscribed = GoogleAppsAccount::account_status($user->id());
     if ($isSubscribed == 'disabled') {
         $isSubscribed = false;
     }
     if ($isSubscribed) {
         Reminder::MarkCandidateAsAccepted($user->id(), $candidate);
     }
     return !$isSubscribed;
 }
Example #17
0
    function jsAlerts()
    {
        global $app_strings;
        $this->script .= <<<EOQ
\t\tif (!alertsTimeoutId) {
\t\t    checkAlerts();
\t\t}

EOQ;
        $this->addActivities();
        Reminder::addNotifications($this);
        if (!empty($GLOBALS['sugar_config']['enable_timeout_alerts'])) {
            $this->addAlert($app_strings['ERROR_JS_ALERT_SYSTEM_CLASS'], $app_strings['ERROR_JS_ALERT_TIMEOUT_TITLE'], '', $app_strings['ERROR_JS_ALERT_TIMEOUT_MSG_1'], (session_cache_expire() - 2) * 60);
            $this->addAlert($app_strings['ERROR_JS_ALERT_SYSTEM_CLASS'], $app_strings['ERROR_JS_ALERT_TIMEOUT_TITLE'], '', $app_strings['ERROR_JS_ALERT_TIMEOUT_MSG_2'], session_cache_expire() * 60, 'index.php');
        }
    }
Example #18
0
 function handler_reminder($page, $reminder_name = null, $action = null)
 {
     require_once 'reminder.inc.php';
     $user = S::user();
     // If no reminder name was passed, or if we don't know that reminder name,
     // just drop the request.
     if (!$reminder_name || !($reminder = Reminder::GetByName($user, $reminder_name))) {
         return PL_NOT_FOUND;
     }
     // Otherwise, the request is dispatched, and a new reminder, if any, is
     // displayed.
     $reminder->HandleAction($action);
     $previous_reminder = $reminder->title();
     if ($new_reminder = Reminder::GetCandidateReminder($user)) {
         $new_reminder->DisplayStandalone($page, $previous_reminder);
     } else {
         $reminder->NotifiesAction($page);
     }
 }
 /**
  * Handle posting of the form for the password reminder confirmation.
  *
  * @param  int  $id
  * @param  string  $code
  * @return \Illuminate\Http\RedirectResponse
  */
 public function processReset($id, $code)
 {
     $rules = ['password' => 'required|confirmed'];
     $validator = Validator::make(Input::get(), $rules);
     if ($validator->fails()) {
         return Redirect::back()->withInput()->withErrors($validator);
     }
     if (!($user = Sentinel::findById($id))) {
         return Redirect::back()->withInput()->withErrors('The user no longer exists.');
     }
     try {
         if (!Reminder::complete($user, $code, Input::get('password'))) {
             return Redirect::route('user.login')->withErrors('Invalid or expired reset code.');
         }
         return Redirect::route('user.login')->withSuccess('Password was successfully resetted.');
     } catch (NotUniquePasswordException $e) {
         return Redirect::back()->withErrors($e->getMessage());
     }
 }
Example #20
0
 /**
  * @see SugarView::display()
  */
 public function display()
 {
     global $json;
     $json = getJSONobj();
     $json_config = new json_config();
     if (isset($this->bean->json_id) && !empty($this->bean->json_id)) {
         $javascript = $json_config->get_static_json_server(false, true, 'Calls', $this->bean->json_id);
     } else {
         $this->bean->json_id = $this->bean->id;
         $javascript = $json_config->get_static_json_server(false, true, 'Calls', $this->bean->id);
     }
     $this->ss->assign('JSON_CONFIG_JAVASCRIPT', $javascript);
     $this->ss->assign('remindersData', Reminder::loadRemindersData('Calls', $this->bean->id));
     $this->ss->assign('remindersDataJson', Reminder::loadRemindersDataJson('Calls', $this->bean->id));
     $this->ss->assign('remindersDefaultValuesDataJson', Reminder::loadRemindersDefaultValuesDataJson());
     $this->ss->assign('remindersDisabled', json_encode(false));
     if ($this->ev->isDuplicate) {
         $this->bean->status = $this->bean->getDefaultStatus();
     }
     //if
     parent::display();
 }
Example #21
0
 /**
  * Generic Function to add Default left join to a request
  *
  * @param $itemtype                    reference ID
  * @param $ref_table                   reference table
  * @param &$already_link_tables  array of tables already joined
  *
  * @return Left join string
  **/
 static function addDefaultJoin($itemtype, $ref_table, array &$already_link_tables)
 {
     switch ($itemtype) {
         // No link
         case 'User':
             return self::addLeftJoin($itemtype, $ref_table, $already_link_tables, "glpi_profiles_users", "profiles_users_id", 0, 0, array('jointype' => 'child'));
         case 'Reminder':
             return Reminder::addVisibilityJoins();
         case 'RSSFeed':
             return RSSFeed::addVisibilityJoins();
         case 'ProjectTask':
             // Same structure in addDefaultWhere
             $out = '';
             $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, "glpi_projecttaskteams", "projecttaskteams_id", 0, 0, array('jointype' => 'child'));
             return $out;
         case 'Project':
             // Same structure in addDefaultWhere
             $out = '';
             if (!Session::haveRight("project", Project::READALL)) {
                 $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, "glpi_projectteams", "projectteams_id", 0, 0, array('jointype' => 'child'));
             }
             return $out;
         case 'Ticket':
             // Same structure in addDefaultWhere
             $out = '';
             if (!Session::haveRight("ticket", Ticket::READALL)) {
                 $searchopt =& self::getOptions($itemtype);
                 // show mine : requester
                 $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, "glpi_tickets_users", "tickets_users_id", 0, 0, $searchopt[4]['joinparams']['beforejoin']['joinparams']);
                 if (Session::haveRight("ticket", Ticket::READGROUP)) {
                     if (count($_SESSION['glpigroups'])) {
                         $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, "glpi_groups_tickets", "groups_tickets_id", 0, 0, $searchopt[71]['joinparams']['beforejoin']['joinparams']);
                     }
                 }
                 // show mine : observer
                 $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, "glpi_tickets_users", "tickets_users_id", 0, 0, $searchopt[66]['joinparams']['beforejoin']['joinparams']);
                 if (count($_SESSION['glpigroups'])) {
                     $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, "glpi_groups_tickets", "groups_tickets_id", 0, 0, $searchopt[65]['joinparams']['beforejoin']['joinparams']);
                 }
                 if (Session::haveRight("ticket", Ticket::OWN)) {
                     // Can own ticket : show assign to me
                     $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, "glpi_tickets_users", "tickets_users_id", 0, 0, $searchopt[5]['joinparams']['beforejoin']['joinparams']);
                 }
                 if (Session::haveRightsOr("ticket", array(Ticket::READMY, Ticket::READASSIGN))) {
                     // show mine + assign to me
                     $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, "glpi_tickets_users", "tickets_users_id", 0, 0, $searchopt[5]['joinparams']['beforejoin']['joinparams']);
                     if (count($_SESSION['glpigroups'])) {
                         $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, "glpi_groups_tickets", "groups_tickets_id", 0, 0, $searchopt[8]['joinparams']['beforejoin']['joinparams']);
                     }
                 }
                 if (Session::haveRightsOr('ticketvalidation', array(TicketValidation::VALIDATEINCIDENT, TicketValidation::VALIDATEREQUEST))) {
                     $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, "glpi_ticketvalidations", "ticketvalidations_id", 0, 0, $searchopt[58]['joinparams']['beforejoin']['joinparams']);
                 }
             }
             return $out;
         case 'Change':
         case 'Problem':
             if ($itemtype == 'Change') {
                 $right = 'change';
                 $table = 'changes';
                 $groupetable = "glpi_changes_groups";
                 $linkfield = "changes_groups_id";
             } else {
                 if ($itemtype == 'Problem') {
                     $right = 'problem';
                     $table = 'problems';
                     $groupetable = "glpi_groups_problems";
                     $linkfield = "groups_problems_id";
                 }
             }
             // Same structure in addDefaultWhere
             $out = '';
             if (!Session::haveRight("{$right}", $itemtype::READALL)) {
                 $searchopt =& self::getOptions($itemtype);
                 if (Session::haveRight("{$right}", $itemtype::READMY)) {
                     // show mine : requester
                     $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, "glpi_" . $table . "_users", $table . "_users_id", 0, 0, $searchopt[4]['joinparams']['beforejoin']['joinparams']);
                     if (count($_SESSION['glpigroups'])) {
                         $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, $groupetable, $linkfield, 0, 0, $searchopt[71]['joinparams']['beforejoin']['joinparams']);
                     }
                     // show mine : observer
                     $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, "glpi_" . $table . "_users", $table . "_users_id", 0, 0, $searchopt[66]['joinparams']['beforejoin']['joinparams']);
                     if (count($_SESSION['glpigroups'])) {
                         $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, $groupetable, $linkfield, 0, 0, $searchopt[65]['joinparams']['beforejoin']['joinparams']);
                     }
                     // show mine : assign
                     $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, "glpi_" . $table . "_users", $table . "_users_id", 0, 0, $searchopt[5]['joinparams']['beforejoin']['joinparams']);
                     if (count($_SESSION['glpigroups'])) {
                         $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, $groupetable, $linkfield, 0, 0, $searchopt[8]['joinparams']['beforejoin']['joinparams']);
                     }
                 }
             }
             return $out;
         default:
             // Plugin can override core definition for its type
             if ($plug = isPluginItemType($itemtype)) {
                 $function = 'plugin_' . $plug['plugin'] . '_addDefaultJoin';
                 if (function_exists($function)) {
                     $out = $function($itemtype, $ref_table, $already_link_tables);
                     if (!empty($out)) {
                         return $out;
                     }
                 }
             }
             return "";
     }
 }
Example #22
0
                if (trim($sql) != '') {
                    logThis('Running sql:' . $sql, $path);
                }
                $repairedTables[$focus->table_name] = true;
            }
            //Check to see if we need to create the audit table
            if ($focus->is_AuditEnabled() && !$focus->db->tableExists($focus->get_audit_table_name())) {
                logThis('Creating audit table:' . $focus->get_audit_table_name(), $path);
                $focus->create_audit_table();
            }
        }
    }
}
// add suite version into upgrade pack!
if (isset($repairedTables['reminders']) && $repairedTables['reminders'] && isset($_SESSION['suitecrm_version_before_upgrade']) && version_compare($_SESSION['suitecrm_version_before_upgrade'], Reminder::UPGRADE_VERSION, '<')) {
    Reminder::upgrade();
    unset($_SESSION['suitecrm_version_before_upgrade']);
}
$olddictionary = $dictionary;
unset($dictionary);
include 'modules/TableDictionary.php';
foreach ($dictionary as $meta) {
    $tablename = $meta['table'];
    if (isset($repairedTables[$tablename])) {
        continue;
    }
    $fielddefs = $meta['fields'];
    $indices = $meta['indices'];
    $sql = $GLOBALS['db']->repairTableParams($tablename, $fielddefs, $indices, true);
    if (trim($sql) != '') {
        logThis('Running sql:' . $sql, $path);
 /**
  *  Generate ical file content
  *
  * @param $who user ID
  * @param $who_group group ID
  *
  * @return icalendar string
  **/
 static function generateIcal($who, $who_group)
 {
     global $CFG_GLPI, $LANG;
     if ($who == 0 && $who_group == 0) {
         return false;
     }
     include_once GLPI_ROOT . "/lib/icalcreator/iCalcreator.class.php";
     $v = new vcalendar();
     if (!empty($CFG_GLPI["version"])) {
         $v->setConfig('unique_id', "GLPI-Planning-" . trim($CFG_GLPI["version"]));
     } else {
         $v->setConfig('unique_id', "GLPI-Planning-UnknownVersion");
     }
     $v->setConfig('filename', "glpi.ics");
     $v->setProperty("method", "PUBLISH");
     $v->setProperty("version", "2.0");
     $v->setProperty("x-wr-calname", "GLPI-" . $who . "-" . $who_group);
     $v->setProperty("calscale", "GREGORIAN");
     $interv = array();
     $begin = time() - MONTH_TIMESTAMP * 12;
     $end = time() + MONTH_TIMESTAMP * 12;
     $begin = date("Y-m-d H:i:s", $begin);
     $end = date("Y-m-d H:i:s", $end);
     // ---------------Tracking
     $interv = TicketPlanning::populatePlanning(array('who' => $who, 'who_group' => $who_group, 'begin' => $begin, 'end' => $end));
     // ---------------Reminder
     $data = Reminder::populatePlanning(array('who' => $who, 'who_group' => $who_group, 'begin' => $begin, 'end' => $end));
     $interv = array_merge($interv, $data);
     // ---------------Plugin
     $data = doHookFunction("planning_populate", array("begin" => $begin, "end" => $end, "who" => $who, "who_group" => $who_group));
     if (isset($data["items"]) && count($data["items"])) {
         $interv = array_merge($data["items"], $interv);
     }
     if (count($interv) > 0) {
         foreach ($interv as $key => $val) {
             $vevent = new vevent();
             //initiate EVENT
             if (isset($val["tickettasks_id"])) {
                 $vevent->setProperty("uid", "Job#" . $val["tickettasks_id"]);
             } else {
                 if (isset($val["reminders_id"])) {
                     $vevent->setProperty("uid", "Event#" . $val["reminders_id"]);
                 } else {
                     if (isset($val['planningID'])) {
                         // Specify the ID (for plugins)
                         $vevent->setProperty("uid", "Plugin#" . $val['planningID']);
                     } else {
                         $vevent->setProperty("uid", "Plugin#" . $key);
                     }
                 }
             }
             $vevent->setProperty("dstamp", $val["begin"]);
             $vevent->setProperty("dtstart", $val["begin"]);
             $vevent->setProperty("dtend", $val["end"]);
             if (isset($val["tickets_id"])) {
                 $vevent->setProperty("summary", $LANG['planning'][8] . " # " . $val["tickets_id"] . " " . $LANG['document'][14] . " # " . $val["device"]);
             } else {
                 if (isset($val["name"])) {
                     $vevent->setProperty("summary", $val["name"]);
                 }
             }
             if (isset($val["content"])) {
                 $vevent->setProperty("description", html_clean($val["content"]));
             } else {
                 if (isset($val["name"])) {
                     $vevent->setProperty("description", $val["name"]);
                 }
             }
             if (isset($val["tickets_id"])) {
                 $vevent->setProperty("url", $CFG_GLPI["url_base"] . "/index.php?redirect=tracking_" . $val["tickets_id"]);
             }
             $v->setComponent($vevent);
         }
     }
     $v->sort();
     //$v->parse();
     return $v->returnCalendar();
 }
        }
        $tpl->assign("info", $info);
    }
    if (!empty($HTTP_GET_VARS['field'])) {
        $field_title = Reminder_Condition::getFieldTitle($HTTP_GET_VARS['field']);
        if (Reminder_Condition::canFieldBeCompared($HTTP_GET_VARS['field'])) {
            $tpl->assign(array('show_field_options' => 'yes', 'comparable_fields' => Reminder_Condition::getFieldAdminList(true)));
        } elseif (strtolower($field_title) == 'status') {
            $prj_id = Reminder::getProjectID($rem_id);
            $tpl->assign(array('show_status_options' => 'yes', 'statuses' => Status::getAssocStatusList($prj_id)));
        } elseif (strtolower($field_title) == 'category') {
            $prj_id = Reminder::getProjectID($rem_id);
            $tpl->assign(array('show_category_options' => 'yes', 'categories' => Category::getAssocList($prj_id)));
        } else {
            $tpl->assign('show_status_options', 'no');
        }
        if (@$HTTP_GET_VARS["cat"] != "edit") {
            $tpl->assign('info', array('rlc_rmf_id' => $HTTP_GET_VARS['field'], 'rlc_rmo_id' => '', 'rlc_value' => ''));
        }
    }
    $tpl->assign("rem_id", $rem_id);
    $tpl->assign("rma_id", $rma_id);
    $tpl->assign("rem_title", Reminder::getTitle($rem_id));
    $tpl->assign("rma_title", Reminder_Action::getTitle($rma_id));
    $tpl->assign("fields", Reminder_Condition::getFieldAdminList());
    $tpl->assign("operators", Reminder_Condition::getOperatorAdminList());
    $tpl->assign("list", Reminder_Condition::getAdminList($rma_id));
} else {
    $tpl->assign("show_not_allowed_msg", true);
}
$tpl->displayTemplate();
Example #25
0
 /**
  * Return a list of related reminders for specified event (Calls/Meetings). Call it from DetailViews.
  * @param SugarBean $event a Call or Meeting Bean
  * @return mixed|string|void output of list (html)
  * @throws Exception on json error in Remainders
  */
 public static function getRemindersListView(SugarBean $event)
 {
     global $mod_strings, $app_list_strings;
     $tpl = new Sugar_Smarty();
     $tpl->assign('MOD', $mod_strings);
     $tpl->assign('reminder_time_options', $app_list_strings['reminder_time_options']);
     $tpl->assign('remindersData', Reminder::loadRemindersData($event->module_name, $event->id));
     $tpl->assign('remindersDataJson', Reminder::loadRemindersDataJson($event->module_name, $event->id));
     $tpl->assign('remindersDefaultValuesDataJson', Reminder::loadRemindersDefaultValuesDataJson());
     $tpl->assign('remindersDisabled', json_encode(true));
     return $tpl->fetch('modules/Reminders/tpls/reminders.tpl');
 }
Example #26
0
 public function access_to_password_reset_page_while_logged_in(FunctionalTester $I)
 {
     $I->am('Unlogged user');
     $I->wantTo('access to the password reset page while logged in');
     $I->expectTo('be redirected to the home page');
     /***************************************************************************************************************
      * run test
      **************************************************************************************************************/
     $user = \Sentinel::authenticate($this->_credentials);
     $reminder = Reminder::create($user);
     $I->amOnPage('/');
     $I->amOnPage(config('app.url') . '/' . config('app.locale') . '/' . trans('routes.password.reset') . '?email=' . $user->email . '&token=' . $reminder->code);
     $I->amOnRoute('home');
 }
Example #27
0
 protected static function MarkCandidateAsAccepted($uid, $candidate)
 {
     Reminder::UpdateStatus($uid, $candidate['type_id'], 'yes', $candidate['remind_delay_yes']);
 }
Example #28
0
    }
    $tpl->assign('info', $info);
}
if (!empty($_GET['field'])) {
    $field_title = Reminder_Condition::getFieldTitle($_GET['field']);
    if (Reminder_Condition::canFieldBeCompared($_GET['field'])) {
        $tpl->assign(array('show_field_options' => 'yes', 'comparable_fields' => Reminder_Condition::getFieldAdminList(true)));
    } elseif (strtolower($field_title) == 'status') {
        $prj_id = Reminder::getProjectID($rem_id);
        $tpl->assign(array('show_status_options' => 'yes', 'statuses' => Status::getAssocStatusList($prj_id)));
    } elseif (strtolower($field_title) == 'category') {
        $prj_id = Reminder::getProjectID($rem_id);
        $tpl->assign(array('show_category_options' => 'yes', 'categories' => Category::getAssocList($prj_id)));
    } elseif (strtolower($field_title) == 'group' || strtolower($field_title) == 'active group') {
        $prj_id = Reminder::getProjectID($rem_id);
        $tpl->assign(array('show_group_options' => 'yes', 'groups' => Group::getAssocList($prj_id)));
    } else {
        $tpl->assign('show_status_options', 'no');
    }
    if (@$_GET['cat'] != 'edit') {
        $tpl->assign('info', array('rlc_rmf_id' => $_GET['field'], 'rlc_rmo_id' => '', 'rlc_value' => ''));
    }
}
$tpl->assign('rem_id', $rem_id);
$tpl->assign('rma_id', $rma_id);
$tpl->assign('rem_title', Reminder::getTitle($rem_id));
$tpl->assign('rma_title', Reminder_Action::getTitle($rma_id));
$tpl->assign('fields', Reminder_Condition::getFieldAdminList());
$tpl->assign('operators', Reminder_Condition::getOperatorAdminList());
$tpl->assign('list', Reminder_Condition::getAdminList($rma_id));
$tpl->displayTemplate();
Example #29
0
 public function getHTML($id)
 {
     #$_SESSION["BPS"]->unregisterClass(get_class($this));
     $defaultAnsicht = "monat";
     if (Applications::activeApplication() == "personalKartei") {
         $defaultAnsicht = "jahr";
     }
     $ansicht = mUserdata::getUDValueS("KalenderAnsicht", $defaultAnsicht);
     #$ansicht = $ansicht->getUDValue("KalenderAnsicht");
     #if($ansicht == null) $ansicht = "monat";
     $display = mUserdata::getUDValueS("KalenderDisplay" . ucfirst($ansicht), "0");
     $BThis = new Button("", "arrow_down", "iconicG");
     $BThis->style("float:left;margin-top:-6px;margin-right:5px;");
     $Calendars = "";
     Registry::reset("Kalender");
     while ($C = Registry::callNext("Kalender", "categories")) {
         if (!$C) {
             continue;
         }
         foreach ($C as $tab) {
             $Calendars .= "<div onclick=\"{$tab->onclick}\">" . ($tab->isCurrent ? $BThis : "") . " {$tab->label}</div>";
         }
     }
     // <editor-fold defaultstate="collapsed" desc="styles">
     $html = "\n\t\t\n\t\t<style type=\"text/css\">\n\t\t.Day {\n\t\t\t-moz-user-select:none;\n\t\t\tborder-left:1px solid #EEE;\n\t\t\tborder-bottom:1px solid #EEE;\n\t\t}\n\t\t\n\t\t/*.Day:hover {\n\t\t\tborder-style:solid;\n\t\t\tborder-width:1px;\n\t\t\tpadding:2px;\n\t\t}*/\n\n\t\t.dayOptions {\n\t\t\tdisplay:none;\n\t\t}\n\n\t\t.Day:hover .dayOptions {\n\t\t\tdisplay:inline;\n\t\t}\n\n\t\t.Termin {\n\t\t\tposition:relative;\n\t\t\tleft:44px;\n\t\t\tcursor:pointer;\n\t\t\twidth:150px;\n\t\t\tfloat:left;\n\t\t\tborder-style:solid;\n\t\t\tborder-width:1px;\n\t\t\tmargin-right:3px;\n\t\t}\n\t\t\n\t\t.KalenderButton {\n\t\t\topacity:0.5;\n\t\t}\n\t\t\n\t\t.KalenderButton:hover {\n\t\t\topacity:1;\n\t\t}\n\t\t\n\t\t.KalenderUser {\n\t\t\tmargin-left:10px;\n\t\t}\n\t\t\n\t\t.KalenderUser div {\n\t\t\tpadding:10px;\n\t\t\tpadding-top:10px;\n\t\t\tpadding-bottom:5px;\n\t\t\tdisplay:inline-block;\n\t\t\tmargin-right:20px;\n\t\t\tcursor:pointer;\n\t\t\tmin-width:150px;\n\t\t}\n\t\t\n\t\t.cellHeight {\n\t\t}\n\t\t\n\t\t.ui-datepicker {\n\t\t\twidth: auto;\n\t\t}\n\n\t\t#contentScreen tr:hover {\n\t\t\tbackground-color:inherit;\n\t\t}\n\n\t\t#calendar1stMonth .ui-datepicker-prev, #calendar1stMonth .ui-datepicker-next/*,\n\t\t#calendar2ndMonth .ui-datepicker-prev, #calendar2ndMonth .ui-datepicker-next */{\n\t\t\tdisplay:none;\n\t\t}\n\t\t\n\t\t#calendar1stMonth .ui-widget-content,\n\t\t#calendar2ndMonth .ui-widget-content, \n\t\t#calendar2ndMonth .ui-widget-content .ui-state-default,\n\t\t#calendar1stMonth .ui-widget-content .ui-state-default {\n\t\t\tborder:0px;\n\t\t}\n\t\t\n\t\t#calendar1stMonth .ui-datepicker-header,\n\t\t#calendar2ndMonth .ui-datepicker-header {\n\t\t\tborder:0px;\n\t\t}\n\t\t\n\t\t/*@media only screen and (max-height: 820px) {\n\t\t\t.cellHeight {\n\t\t\t\theight:55px;\n\t\t\t}\n\t\t}*/\n\t\t</style>";
     // </editor-fold>
     $BLeft = new Button("Zurück", "back", "icon");
     $BLeft->rmePCR("mKalender", "", "setDisplay", $display - 1, "contentManager.loadFrame('contentScreen','mKalender');");
     $BLeft->style("margin-right:10px;");
     $BRight = new Button("Weiter", "navigation", "icon");
     $BRight->rmePCR("mKalender", "", "setDisplay", $display + 1, "contentManager.loadFrame('contentScreen','mKalender');");
     $BRight->style("margin-right:10px;");
     $BToday = new Button("Aktuelles Datum", "down", "icon");
     $BToday->rmePCR("mKalender", "", "setToday", '', "contentManager.loadFrame('contentScreen','mKalender');");
     $BToday->style("margin-right:10px;");
     $BJahr = new Button("Jahr", "./ubiquitous/Kalender/month.png", "icon");
     $BJahr->rmePCR("mKalender", "", "setView", "jahr", "contentManager.loadFrame('contentScreen','mKalender');");
     $BJahr->style("margin-right:10px;" . ($ansicht != "jahr" ? "opacity:0.5;" : ""));
     $BJahr->id("jahrButton");
     $BMonat = new Button("Monat", "./ubiquitous/Kalender/month.png", "icon");
     $BMonat->rmePCR("mKalender", "", "setView", "monat", "contentManager.loadFrame('contentScreen','mKalender');");
     $BMonat->style("margin-right:10px;" . ($ansicht != "monat" ? "opacity:0.5;" : ""));
     $BMonat->id("monatButton");
     $BWoche = new Button("Woche", "./ubiquitous/Kalender/workweek.png", "icon");
     $BWoche->rmePCR("mKalender", "", "setView", "woche", "contentManager.loadFrame('contentScreen','mKalender');");
     $BWoche->style("margin-right:10px;" . ($ansicht != "woche" ? "opacity:0.5;" : ""));
     $BWoche->id("wocheButton");
     $BTag = new Button("Tag", "./ubiquitous/Kalender/day.png", "icon");
     $BTag->rmePCR("mKalender", "", "setView", "tag", "contentManager.loadFrame('contentScreen','mKalender');");
     $BTag->style("margin-right:10px;" . ($ansicht != "tag" ? "opacity:0.5;" : ""));
     $BTag->id("tagButton");
     if (Applications::activeApplication() == "personalKartei") {
         $BTag = "";
         $BWoche = "";
         $BMonat = "";
     }
     if (Applications::activeApplication() != "personalKartei") {
         $BJahr = "";
     }
     $ST = new HTMLTable(1);
     $ST->setColClass(1, "");
     #$ST->setTableStyle("width:40px;margin:0px;margin-right:-215px;float:right;/*margin-right:-50px;margin-top:95px;*/");
     $newWindow = new Button("Kalender in neuem Fenster öffnen", "new_window", "iconicL");
     $newWindow->style("margin-right:10px;");
     $newWindow->newSession("Mail", Applications::activeApplication(), "mKalender", "Kalender");
     if (Session::physion()) {
         $newWindow = "";
     }
     $reminder = "";
     if (Session::isPluginLoaded("mReminder")) {
         $reminder = Reminder::getButton();
         $reminder->style("margin-right:10px;");
     }
     $ST->addRow("<div id=\"calendar1stMonth\"></div>");
     $ST->addRow("<div id=\"calendar2ndMonth\"></div>");
     $TC = "KalenderView" . ucfirst($ansicht);
     $TC = new $TC();
     $TCalendars = "<div>";
     if (trim($Calendars) != "") {
         $TCalendars .= "<div class=\"KalenderUser\">" . $Calendars . "</div>";
     }
     $TCalendars .= "</div>";
     $pCalButton = "";
     if (Session::isPluginLoaded("mpCal")) {
         $pCalButton = pCal::getTBButton();
         $pCalButton->type("icon");
         $pCalButton->style("margin-right:10px;");
     }
     $GoogleButton = "";
     $GoogleDLButton = "";
     if (Session::isPluginLoaded("mGoogle")) {
         $GoogleButton = LoginData::getButtonU("GoogleAccountUserPass", "Google-Daten bearbeiten", "./ubiquitous/Google/google.png");
         $GoogleButton->type("icon");
         $GoogleButton->style("margin-right:10px;");
         $GoogleDLButton = new Button("Daten herunterladen", "./ubiquitous/Google/googleDL.png", "icon");
         $GoogleDLButton->popup("", "Daten herunterladen", "Google", "-1", "syncByDateRange", array("'" . date("Y-m-d", $TC->getFirst()) . "'", "'" . date("Y-m-d", $TC->getLast()) . "'"));
         $GoogleDLButton->style("margin-right:10px;");
     }
     $xCalButton = "";
     if (Session::isPluginLoaded("mxCal")) {
         $xCalButton = xCal::getButton();
         $xCalButton->style("margin-right:10px;");
     }
     $BShare = new Button("Kalender teilen", "fork", "iconicL");
     $BShare->popup("", "Kalender teilen", "mKalender", "-1", "share");
     $BShare->style("margin-right:10px;");
     #$AWVButton = new Button("Müllabfuhr-Daten herunterladen", "trash_stroke", "iconicL");
     #$AWVButton->popup("", "Müllabfuhr-Daten", "mKalender", "-1", "downloadTrashData");
     $AWVButton = "";
     $ST->addRow($pCalButton . $GoogleButton . $GoogleDLButton);
     $html .= "\n\t\t<div style=\"width:205px;float:right;margin-right:40px;\">\n\t\t\t\t<div style=\"padding-top:30px;padding-bottom:15px;padding-left:0px;\">\n\t\t\t\t\t{$newWindow}{$BShare}{$AWVButton}{$xCalButton}{$reminder}\n\t\t\t\t</div>\n\t\t</div>\n\t\t\n\t\t<div style=\"margin-right:270px;\">\n\t\t<div id=\"KalenderTitle\" class=\"prettyTitle\">\n\t\t\t\n\t\t\t<span style=\"float:right;\">\n\t\t\t\t{$BLeft}{$BToday}{$BRight}\n\t\t\t</span>\n\t\t\t<div style=\"float:right;margin-right:100px;\">{$BTag}{$BWoche}{$BMonat}{$BJahr}</div>\n\t\t\t" . $TC->getTitle() . "\n\t\t</div>\n\t\t</div>\n\t\t<div id=\"KalenderAuswahl\">\n\t\t\t{$TCalendars}\n\t\t</div>\n\t\t" . $TC->getHeader() . "\n\t\t<div id=\"KalenderWrapper\" style=\"overflow:auto;\">\n\t\t\t" . ($ansicht != "jahr" ? "\n\t\t\t<div style=\"width:205px;float:right;margin-right:40px;\">\n\t\t\t\t<div style=\"height:23px;\"></div>{$ST}\n\t\t\t</div>" : "") . "\n\t\t\t<div style=\"" . ($ansicht != "jahr" ? "margin-right:270px;" : "") . "\">\n\n\t\t\t" . $TC->getTable($this) . "\n\t\t\t</div>\n\t\t</div>";
     $nextMonths = new Datum();
     $nextMonths->setToMonth1st();
     $thisMonth = $nextMonths->time();
     $nextMonths->addMonth();
     $nextMonth = $nextMonths->time();
     $html .= OnEvent::script("\$j(function() {\n\t\t\$j('#calendar1stMonth').datepicker({ minDate: '" . date("d.m.Y", $thisMonth) . "'" . ($TC->getCurrent()->time() < $nextMonth ? ",defaultDate: '" . date("d.m.Y", $TC->getCurrent()->time()) . "'" : "") . ", showWeek: true,  showOtherMonths: true, onSelect: function(dateText, inst) { var day = Math.round(+new Date(inst.selectedYear, inst.selectedMonth, inst.selectedDay, 0, 1, 0)/1000); " . OnEvent::rme($this, "setView", array("'tag'", "day"), "function(){ " . OnEvent::reload("Screen") . " }") . " } });\n\t\t\t\n\t\t\$j('.KalenderUser div[class!=backgroundColor1]').hover(function(){ \$j(this).addClass('backgroundColor2'); }, function(){ \$j(this).removeClass('backgroundColor2'); });\n\t\tfitKalender();\n\t\t\t\n\t\t\$j(window).resize(function() {\n\t\t\tfitKalender();\n\t\t});\n\t\t\n\t\t});\n\t\t\n\t\tfunction fitKalender(){\n\t\t\tif(!\$j('#KalenderTitle').length)\n\t\t\t\treturn;\n\t\t\t\n\t\t\t//console.log(\$j('#KalenderTitle').outerHeight());\n\t\t\t//console.log(\$j('#KalenderAuswahl').outerHeight());\n\t\t\tvar height = (contentManager.maxHeight() - \$j('#KalenderAuswahl').outerHeight() - \$j('#KalenderTitle').outerHeight() - \$j('#KalenderHeader').outerHeight()) + 4;\n\t\t\tvar width = contentManager.maxWidth();\n\t\t\t\n\t\t\t\$j('#KalenderWrapper').css('height', height);\n\t\t\t\$j('#KalenderWrapper').css('width', width);\n\n\t\t\tvar cellHeight = (height - \$j('#KalenderTable tr:first th').parent().outerHeight()) / (\$j('#KalenderTable tr').length - " . (($ansicht == "monat" or $ansicht == "jahr") ? "1" : "0") . ") - 1;\n\t\t\t\$j('.cellHeight').css('height', cellHeight+'px');\n\t\t\t\$j('.innerCellHeight').css('height', (cellHeight - \$j('.innerCellTitle:visible').outerHeight())+'px');\n\t\t\t\n\t\t\tif(\$j('#KalenderHeader').length > 0){\n\t\t\t\t//console.log(\$j('#KalenderHeader tr:first th'));\n\t\t\t\t\$j('#KalenderTable tr:first td').each(function(k, v){\n\t\t\t\t\t\n\t\t\t\t\t\$j(\$j('#KalenderHeader tr:first th')[k]).css('width', \$j(v).width());\n\t\t\t\t});\n\t\t\t}\n\t\t\t\n\t\t\tif(\$j('#tagDiv').length) {\n\t\t\t\t\$j('#tagDiv').css('width', \$j('#KalenderTable tr').width()+'px');\n\t\t\t\t\$j('#tagDiv').animate({scrollTop: 7*40}, 0);\n\t\t\t\tvar pos = \$j('#tagDiv').offset();\n\t\t\t\tpos.position = 'absolute';\n\n\t\t\t\t\$j('#tagDiv').css(pos)\n\t\t\t}\n\t\t}") . "\n\t\t<style type=\"text/css\">\n\t\t\t" . ($TC->getCurrent()->time() < $thisMonth ? "#calendar1stMonth .ui-state-default { border: 1px solid #D3D3D3; background-color:transparent; }" : "") . "\n\t\t\t" . ($TC->getCurrent()->time() < $nextMonth ? "#calendar2ndMonth .ui-state-default { border: 1px solid #D3D3D3; background-color:transparent; }" : "") . "\n\t\t\t.ui-datepicker-week-col { color:grey; text-align:left; }\n\t\t\ttr td.ui-datepicker-week-col {text-align:left;font-size:10px; }\n\t\t\t/*.ui-datepicker-week-end { background-color:#DDD; }*/\n\t\t</style>";
     $html .= OnEvent::script("\$j(function() {\n\t\t\$j('#calendar2ndMonth').datepicker({ minDate: '" . date("d.m.Y", $nextMonth) . "'" . ($TC->getCurrent()->time() >= $nextMonth ? ", defaultDate: '" . date("d.m.Y", $TC->getCurrent()->time()) . "'" : "") . ", showWeek: true, showOtherMonths: true,  onSelect: function(dateText, inst) { var day = Math.round(+new Date(inst.selectedYear, inst.selectedMonth, inst.selectedDay, 0, 1, 0)/1000); " . OnEvent::rme($this, "setView", array("'tag'", "day"), "function(){ " . OnEvent::reload("Screen") . " }") . " } });\n\t});");
     return $html;
 }
 /**
  * Check is the curent user is allowed to see the file
  *
  * @param $options array of options (only 'tickets_id' used)
  *
  * @return boolean
  **/
 function canViewFile($options)
 {
     global $DB, $CFG_GLPI;
     if (isset($_SESSION["glpiactiveprofile"]["interface"]) && $_SESSION["glpiactiveprofile"]["interface"] == "central") {
         // My doc Check and Common doc right access
         if ($this->can($this->fields["id"], READ) || $this->fields["users_id"] === Session::getLoginUserID()) {
             return true;
         }
         // Reminder Case
         $query = "SELECT *\n                   FROM `glpi_documents_items`\n                   LEFT JOIN `glpi_reminders`\n                        ON (`glpi_reminders`.`id` = `glpi_documents_items`.`items_id`\n                            AND `glpi_documents_items`.`itemtype` = 'Reminder')\n                   " . Reminder::addVisibilityJoins() . "\n                   WHERE `glpi_documents_items`.`documents_id` = '" . $this->fields["id"] . "'\n                         AND " . Reminder::addVisibilityRestrict();
         $result = $DB->query($query);
         if ($DB->numrows($result) > 0) {
             return true;
         }
         // Knowbase Case
         if (Session::haveRight("knowbase", READ)) {
             $query = "SELECT *\n                      FROM `glpi_documents_items`\n                      LEFT JOIN `glpi_knowbaseitems`\n                           ON (`glpi_knowbaseitems`.`id` = `glpi_documents_items`.`items_id`\n                               AND `glpi_documents_items`.`itemtype` = 'KnowbaseItem')\n                      " . KnowbaseItem::addVisibilityJoins() . "\n                      WHERE `glpi_documents_items`.`documents_id` = '" . $this->fields["id"] . "'\n                            AND " . KnowbaseItem::addVisibilityRestrict();
             $result = $DB->query($query);
             if ($DB->numrows($result) > 0) {
                 return true;
             }
         }
         if (Session::haveRight('knowbase', KnowbaseItem::READFAQ)) {
             $query = "SELECT *\n                      FROM `glpi_documents_items`\n                      LEFT JOIN `glpi_knowbaseitems`\n                           ON (`glpi_knowbaseitems`.`id` = `glpi_documents_items`.`items_id`\n                               AND `glpi_documents_items`.`itemtype` = 'KnowbaseItem')\n                      " . KnowbaseItem::addVisibilityJoins() . "\n                      WHERE `glpi_documents_items`.`documents_id` = '" . $this->fields["id"] . "'\n                            AND `glpi_knowbaseitems`.`is_faq` = '1'\n                            AND " . KnowbaseItem::addVisibilityRestrict();
             $result = $DB->query($query);
             if ($DB->numrows($result) > 0) {
                 return true;
             }
         }
         // Tracking Case
         if (isset($options["tickets_id"])) {
             $job = new Ticket();
             if ($job->can($options["tickets_id"], READ)) {
                 $query = "SELECT *\n                         FROM `glpi_documents_items`\n                         WHERE `glpi_documents_items`.`items_id` = '" . $options["tickets_id"] . "'\n                               AND `glpi_documents_items`.`itemtype` = 'Ticket'\n                               AND `documents_id`='" . $this->fields["id"] . "'";
                 $result = $DB->query($query);
                 if ($DB->numrows($result) > 0) {
                     return true;
                 }
             }
         }
     } else {
         if (Session::getLoginUserID()) {
             // ! central
             // Check if it is my doc
             if ($this->fields["users_id"] === Session::getLoginUserID()) {
                 return true;
             }
             // Reminder Case
             $query = "SELECT *\n                   FROM `glpi_documents_items`\n                   LEFT JOIN `glpi_reminders`\n                        ON (`glpi_reminders`.`id` = `glpi_documents_items`.`items_id`\n                            AND `glpi_documents_items`.`itemtype` = 'Reminder')\n                   " . Reminder::addVisibilityJoins() . "\n                   WHERE `glpi_documents_items`.`documents_id` = '" . $this->fields["id"] . "'\n                         AND " . Reminder::addVisibilityRestrict();
             $result = $DB->query($query);
             if ($DB->numrows($result) > 0) {
                 return true;
             }
             if (Session::haveRight('knowbase', KnowbaseItem::READFAQ)) {
                 // Check if it is a FAQ document
                 $query = "SELECT *\n                      FROM `glpi_documents_items`\n                      LEFT JOIN `glpi_knowbaseitems`\n                           ON (`glpi_knowbaseitems`.`id` = `glpi_documents_items`.`items_id`)\n                      " . KnowbaseItem::addVisibilityJoins() . "\n                      WHERE `glpi_documents_items`.`itemtype` = 'KnowbaseItem'\n                            AND `glpi_documents_items`.`documents_id` = '" . $this->fields["id"] . "'\n                            AND `glpi_knowbaseitems`.`is_faq` = '1'\n                            AND " . KnowbaseItem::addVisibilityRestrict();
                 $result = $DB->query($query);
                 if ($DB->numrows($result) > 0) {
                     return true;
                 }
             }
             // Tracking Case
             if (isset($options["tickets_id"])) {
                 $job = new Ticket();
                 if ($job->can($options["tickets_id"], READ)) {
                     $query = "SELECT *\n                         FROM `glpi_documents_items`\n                         WHERE `glpi_documents_items`.`items_id` = '" . $options["tickets_id"] . "'\n                               AND `glpi_documents_items`.`itemtype` = 'Ticket'\n                               AND `documents_id` = '" . $this->fields["id"] . "'";
                     $result = $DB->query($query);
                     if ($DB->numrows($result) > 0) {
                         return true;
                     }
                 }
             }
         }
     }
     // Public FAQ for not connected user
     if ($CFG_GLPI["use_public_faq"]) {
         $query = "SELECT *\n                   FROM `glpi_documents_items`\n                   LEFT JOIN `glpi_knowbaseitems`\n                        ON (`glpi_knowbaseitems`.`id` = `glpi_documents_items`.`items_id`)\n                   LEFT JOIN `glpi_entities_knowbaseitems`\n                        ON (`glpi_knowbaseitems`.`id` = `glpi_entities_knowbaseitems`.`knowbaseitems_id`)\n                   WHERE `glpi_documents_items`.`itemtype` = 'KnowbaseItem'\n                         AND `glpi_documents_items`.`documents_id` = '" . $this->fields["id"] . "'\n                         AND `glpi_knowbaseitems`.`is_faq` = '1'\n                         AND `glpi_entities_knowbaseitems`.`entities_id` = '0'\n                         AND `glpi_entities_knowbaseitems`.`is_recursive` = '1'";
         $result = $DB->query($query);
         if ($DB->numrows($result) > 0) {
             return true;
         }
     }
     return false;
 }