Пример #1
0
 public static function getUserActivity($id = null, $sidebar = true)
 {
     $storage = wa()->getStorage();
     $app_session_datetime = $storage->read(self::$app_id . "_session_datetime");
     if (!$app_session_datetime && ($id || is_null($id) && ($id = wa()->getUser()->getId()))) {
         $contact = new waContactSettingsModel();
         $result = $contact->get($id, self::$app_id);
         if (!$app_session_datetime) {
             $app_last_datetime = isset($result[self::$app_id . "_last_datetime"]) ? $result[self::$app_id . "_last_datetime"] : false;
             $app_session_datetime = $app_last_datetime ? $app_last_datetime : self::setUserActivity($id);
             $storage->write(self::$app_id . "_badge_datetime", $app_session_datetime);
         }
         $storage->set(self::$app_id . "_session_datetime", $app_session_datetime);
     } else {
         if ($app_session_datetime) {
             self::setUserActivity($id, 0);
         } else {
             $storage->write(self::$app_id . "_session_datetime", $app_session_datetime = self::setUserActivity($id));
         }
     }
     if (!$sidebar && ($t = $storage->get(self::$app_id . "_badge_datetime"))) {
         $app_session_datetime = $t;
     }
     return $app_session_datetime;
 }
Пример #2
0
 /**
  * Returns the properties of a cointact relating to specified app.
  *
  * @param string|null $app_id App id
  * @param string|null $name Id of the contact property associated with the specified app which must be returned. If
  *      not specified, an associative array of all properties of a contact is returned, which are associated with
  *      the specified app.
  * @param string|null $default The default value, which must be returned, if the specified contact property for the
  *     specified app is not available. If contact property id is not specified for $default parameter, then the
  *     value of $default parameter is ignored.
  * @return mixed
  */
 public function getSettings($app_id, $name = null, $default = null)
 {
     // For general settings
     if (!$app_id) {
         $app_id = '';
     }
     // Get settings for app from database
     if (!isset($this->settings[$app_id])) {
         $setting_model = new waContactSettingsModel();
         $this->settings[$app_id] = $setting_model->get($this->id, $app_id);
     }
     if ($name) {
         return isset($this->settings[$app_id][$name]) ? $this->settings[$app_id][$name] : $default;
     } else {
         return $this->settings[$app_id];
     }
 }