示例#1
0
 private static function _getObject(Resultset $rs, Project $project, User $user)
 {
     if (empty($user) || !$user instanceof User || empty($project) || !$project instanceof Project) {
         return false;
     }
     $ret = new self($project, $user, $rs->getAccess());
     //
     // The following is a workaround on the fact that the translation of this
     // serialized object to the database gets all broken, due to the fact of PHP
     // introducing NULL bytes around the '*' that is prepended before protected
     // variable members, in the serialized mode. This method replaces those
     // problematic NULL bytes with an identifier string '~~NULL_BYTE~~',
     // rendering serialization and unserialization of these specific kinds of
     // object safe. Credits to travis@travishegner.com on:
     // http://pt.php.net/manual/en/function.serialize.php#96504
     //
     $unsafeSerializedNotifications = str_replace(CINTIENT_NULL_BYTE_TOKEN, "", $rs->getNotifications());
     if (($notifications = unserialize($unsafeSerializedNotifications)) === false || !$notifications instanceof NotificationSettings) {
         $notifications = new NotificationSettings($project, $user);
     }
     $ret->setNotifications($notifications);
     $ret->resetSignature();
     // Update user and project for these notification settings
     $notifications->setPtrProject($project);
     $notifications->setPtrUser($user);
     return $ret;
 }