当前位置: 首页>>代码示例>>PHP>>正文


PHP DateUtil::getDatetime方法代码示例

本文整理汇总了PHP中DateUtil::getDatetime方法的典型用法代码示例。如果您正苦于以下问题:PHP DateUtil::getDatetime方法的具体用法?PHP DateUtil::getDatetime怎么用?PHP DateUtil::getDatetime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DateUtil的用法示例。


在下文中一共展示了DateUtil::getDatetime方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getContent

 public function getContent($args)
 {
     switch ($args['pluginid']) {
         case 1:
             //$uid = $args['uid'];
             // Get matching news stories published since last newsletter
             // No selection on categories made !!
             $items = ModUtil::apiFunc('News', 'user', 'getall',
                             array('numitems' => $this->getVar('itemsperpage'),
                                 'status' => 0,
                                 'from' => DateUtil::getDatetime($args['last']),
                                 'filterbydate' => true));
             if ($items != false) {
                 if ($args['contenttype'] == 't') {
                     $counter = 0;
                     $output.="\n";
                     foreach ($items as $item) {
                         $counter++;
                         $output .= $counter . '. ' . $item['title'] . " (" . $this->__f('by %1$s on %2$s', array($item['contributor'], DateUtil::formatDatetime($item['from'], 'datebrief'))) . ")\n";
                     }
                 } else {
                     $render = Zikula_View::getInstance('News');
                     $render->assign('readperm', SecurityUtil::checkPermission('News::', "::", ACCESS_READ));
                     $render->assign('articles', $items);
                     $output = $render->fetch('mailz/listarticles.tpl');
                 }
             } else {
                 $output = $this->__f('No News publisher articles since last newsletter on %s.', DateUtil::formatDatetime($args['last'], 'datebrief')) . "\n";
             }
             return $output;
     }
     return '';
 }
开发者ID:projectesIF,项目名称:Sirius,代码行数:33,代码来源:Mailz.php

示例2: insert

 public function insert($timestamp, array &$obj)
 {
     $obj = new TimeIt_Model_EventDate();
     $obj->eid = $obj['id'];
     $obj->date = DateUtil::getDatetime($timestamp, DATEONLYFORMAT_FIXED);
     $obj->cid = $obj['cid'];
     $obj->save();
 }
开发者ID:planetenkiller,项目名称:TimeIt,代码行数:8,代码来源:DB.php

示例3: getPluginData

 function getPluginData($filtAfterDate = null)
 {
     if (!$this->pluginAvailable()) {
         return array();
     }
     if (!SecurityUtil::checkPermission('ZphpBB2::', '::', ACCESS_READ, $this->userNewsletter)) {
         return array();
     }
     //ModUtil::load('ZphpBB2');
     $table_prefix = ModUtil::getVar('ZphpBB2', 'table_prefix', 'phpbb_');
     $TOPICS_TABLE = $table_prefix . "topics";
     $POSTS_TABLE = $table_prefix . "posts";
     $POSTS_TEXT_TABLE = $table_prefix . "posts_text";
     $FORUMS_TABLE = $table_prefix . "forums";
     $connection = Doctrine_Manager::getInstance()->getCurrentConnection();
     $sql = "SELECT forum_id, forum_name FROM {$FORUMS_TABLE} WHERE auth_view <= 0 AND auth_read <= 0";
     $stmt = $connection->prepare($sql);
     try {
         $stmt->execute();
     } catch (Exception $e) {
         return LogUtil::registerError(__('Error in plugin') . ' ZphpBB2: ' . $e->getMessage());
     }
     $userforums = $stmt->fetchAll(Doctrine_Core::FETCH_ASSOC);
     $allowedforums = array();
     foreach (array_keys($userforums) as $k) {
         if (SecurityUtil::checkPermission('ZphpBB2::', ":" . $userforums[$k]['forum_id'] . ":", ACCESS_READ, $this->userNewsletter)) {
             $allowedforums[] = $userforums[$k]['forum_id'];
         }
     }
     if (count($allowedforums) == 0) {
         // user is not allowed to read any forum at all
         return array();
     }
     $sql = "SELECT {$TOPICS_TABLE}.topic_title, {$TOPICS_TABLE}.topic_replies, {$TOPICS_TABLE}.topic_views, {$TOPICS_TABLE}.topic_id, \n                     {$POSTS_TABLE}.post_id, {$POSTS_TABLE}.poster_id, {$POSTS_TABLE}.post_time, \n                     {$POSTS_TEXT_TABLE}.post_subject, {$POSTS_TEXT_TABLE}.post_text, \n                     {$FORUMS_TABLE}.forum_name \n                     FROM {$TOPICS_TABLE} \n                     INNER JOIN {$POSTS_TABLE} ON {$POSTS_TABLE}.topic_id = {$TOPICS_TABLE}.topic_id \n                     INNER JOIN {$POSTS_TEXT_TABLE} ON {$POSTS_TEXT_TABLE}.post_id = {$POSTS_TABLE}.post_id \n                     INNER JOIN {$FORUMS_TABLE} ON {$FORUMS_TABLE}.forum_id = {$TOPICS_TABLE}.forum_id";
     $sql .= " WHERE {$TOPICS_TABLE}.forum_id IN (" . implode(',', $allowedforums) . ")";
     if ($filtAfterDate) {
         $sql .= " AND FROM_UNIXTIME(post_time)>='" . $filtAfterDate . "'";
     }
     $sql .= " ORDER BY post_time DESC LIMIT " . $this->nItems;
     $stmt = $connection->prepare($sql);
     try {
         $stmt->execute();
     } catch (Exception $e) {
         return LogUtil::registerError(__('Error in plugin') . ' ZphpBB2: ' . $e->getMessage());
     }
     $items = $stmt->fetchAll(Doctrine_Core::FETCH_BOTH);
     foreach (array_keys($items) as $k) {
         $items[$k]['topicurl'] = ModUtil::url('ZphpBB2', 'user', 'viewtopic', array('t' => $items[$k]['topic_id']));
         $items[$k]['posturl'] = ModUtil::url('ZphpBB2', 'user', 'viewtopic', array('p' => $items[$k]['post_id'] . '#' . $items[$k]['post_id']));
         $items[$k]['postdate'] = DateUtil::getDatetime($items[$k]['post_time']);
         $items[$k]['username'] = UserUtil::getVar('uname', $items[$k]['poster_id']);
         $items[$k]['nl_title'] = $items[$k]['topic_title'];
         $items[$k]['nl_url_title'] = System::getBaseUrl() . $items[$k]['posturl'];
         $items[$k]['nl_content'] = $items[$k]['forum_name'] . ', ' . $items[$k]['username'] . "<br />\n" . $items[$k]['post_text'];
         $items[$k]['nl_url_readmore'] = $items[$k]['nl_url_title'];
     }
     return $items;
 }
开发者ID:nmpetkov,项目名称:ZphpBB2,代码行数:58,代码来源:ZphpBB2.php

示例4: smarty_modifier_dateformatHuman

/**
 * Smarty modifier to format datetimes in a more Human Readable form 
 * (like tomorow, 4 days from now, 6 hours ago)
 *
 * Example
 * <!--[$futuredate|dateformatHuman:'%x':'2']-->
 *
 * @author   Erik Spaan
 * @since    05/03/09
 * @param    string   $string   input datetime string
 * @param    string   $format   The format of the regular date output (default %x)
 * @param    string   $niceval  [1|2|3|4] Choose the nice value of the output (default 2)
 *                                    1 = full human readable
 *                                    2 = past date > 1 day with dateformat, otherwise human readable
 *                                    3 = within 1 day human readable, otherwise dateformat
 *                                    4 = only use the specified format
 * @return   string   the modified output
 */
function smarty_modifier_dateformatHuman($string, $format = '%x', $niceval = 2)
{
    $dom = ZLanguage::getModuleDomain('News');
    if (empty($format)) {
        $format = '%x';
    }
    // store the current datetime in a variable
    $now = DateUtil::getDatetime();
    if (empty($string)) {
        return DateUtil::formatDatetime($now, $format);
    }
    if (empty($niceval)) {
        $niceval = 2;
    }
    // now format the date with respect to the current datetime
    $res = '';
    $diff = DateUtil::getDatetimeDiff($now, $string);
    if ($diff['d'] < 0) {
        if ($niceval == 1) {
            $res = _fn('%s day ago', '%s days ago', abs($diff['d']), abs($diff['d']), $dom);
        } elseif ($niceval < 4 && $diff['d'] == -1) {
            $res = __('yesterday', $dom);
        } else {
            $res = DateUtil::formatDatetime($string, $format);
        }
    } elseif ($diff['d'] > 0) {
        if ($niceval > 2) {
            $res = DateUtil::formatDatetime($string, $format);
        } elseif ($diff['d'] == 1) {
            $res = __('tomorrow', $dom);
        } else {
            $res = _fn('%s day from now', '%s days from now', $diff['d'], $diff['d'], $dom);
        }
    } else {
        // no day difference
        if ($diff['h'] < 0) {
            $res = _fn('%s hour ago', '%s hours ago', abs($diff['h']), abs($diff['h']), $dom);
        } elseif ($diff['h'] > 0) {
            $res = _fn('%s hour from now', '%s hours from now', $diff['h'], $diff['h'], $dom);
        } else {
            // no hour difference
            if ($diff['m'] < 0) {
                $res = _fn('%s minute ago', '%s minutes ago', abs($diff['m']), abs($diff['m']), $dom);
            } elseif ($diff['m'] > 0) {
                $res = _fn('%s minute from now', '%s minutes from now', $diff['m'], $diff['m'], $dom);
            } else {
                // no min difference
                if ($diff['s'] < 0) {
                    $res = _fn('%s second ago', '%s seconds ago', abs($diff['s']), abs($diff['s']), $dom);
                } else {
                    $res = _fn('%s second from now', '%s seconds from now', $diff['s'], $diff['s'], $dom);
                }
            }
        }
    }
    return $res;
}
开发者ID:aksiide,项目名称:SuperPlugin-generator,代码行数:75,代码来源:modifier.dateformatHuman.php

示例5: dateConvert

 /**
  * Convert the date to a more useful format.
  *
  * @param string $date Date string.
  *
  * @return string Converted date
  */
 protected function dateConvert($date)
 {
     if (strptime($date, "%d.%m.%Y %H:%M:%S") !== false) {
         $arr = strptime($date, "%d.%m.%Y %H:%M:%S");
         $time = \DateUtil::buildDatetime($arr['tm_year'], $arr['tm_mon'], $arr['tm_monday'], $arr['tm_hour'], $arr['tm_min'], $arr['tm_sec']);
     } elseif (is_numeric($date)) {
         $time = \DateUtil::getDatetime($date);
     } else {
         $time = str_replace('_', ' ', $date);
     }
     return $time;
 }
开发者ID:rmaiwald,项目名称:core,代码行数:19,代码来源:DatePlugin.php

示例6: mediashare_invitationapi_createInvitationId

function mediashare_invitationapi_createInvitationId($args)
{
    $dom = ZLanguage::getModuleDomain('mediashare');
    do {
        $key = mediashareCreateInvitationKey();
        $record = array('albumId' => (int) $args['albumId'], 'created' => DateUtil::getDatetime(), 'key' => $key, 'email' => $args['email'], 'subject' => $args['subject'], 'text' => $args['text'], 'sender' => $args['sender'], 'expires' => !empty($args['expires']) ? $args['expires'] : null);
        $result = DBUtil::insertObject($record, 'mediashare_invitation', 'id');
        if ($result == false) {
            return LogUtil::registerError(__f('Error in %1$s: %2$s.', array('invitationapi.createInvitationId', 'Could not create the invitation.'), $dom));
        }
    } while (false);
    // FIXME: add "key exists" check
    return $key;
}
开发者ID:ro0f,项目名称:Mediashare,代码行数:14,代码来源:pninvitationapi.php

示例7: smarty_function_dateformat

/**
 * DateFormat.
 *
 * Params can be:
 *  format   The date format we wish to convert to (optional) (default='Y-m-d').
 *  datetime The datetime we wish to convert.
 *  assign   The smarty variable we wish to assign the result to (optional).
 *
 * @param array       $params All attributes passed to this function from the template.
 * @param Zikula_View $view   Reference to the Zikula_View object.
 *
 * @return string
 */
function smarty_function_dateformat($params, Zikula_View $view)
{
    if (!isset($params['datetime'])) {
        $params['datetime'] = null;
    }
    if (!isset($params['format']) || empty($params['format'])) {
        $params['format'] = null;
    }
    $res = DateUtil::getDatetime($params['datetime'], $params['format']);
    if (isset($params['assign']) && $params['assign']) {
        $view->assign($params['assign'], $res);
    } else {
        return $res;
    }
}
开发者ID:planetenkiller,项目名称:core,代码行数:28,代码来源:function.dateformat.php

示例8: search

    /**
     * Search plugin main function
     **/
    public function search($args)
    {
        if (!SecurityUtil::checkPermission('News::', '::', ACCESS_READ)) {
            return true;
        }

        ModUtil::dbInfoLoad('Search');
        $tables = DBUtil::getTables();
        $newsColumn = $tables['news_column'];

        $where = Search_Api_User::construct_where($args,
                array($newsColumn['title'],
                $newsColumn['hometext'],
                $newsColumn['bodytext']),
                $newsColumn['language']);
        // Only search in published articles that are currently visible
        $where .= " AND ({$newsColumn['published_status']} = '0')";
        $date = DateUtil::getDatetime();
        $where .= " AND ('$date' >= {$newsColumn['from']} AND ({$newsColumn['to']} IS NULL OR '$date' <= {$newsColumn['to']}))";

        $sessionId = session_id();

        ModUtil::loadApi('News', 'user');

        $permChecker = new News_ResultChecker($this->getVar('enablecategorization'), $this->getVar('enablecategorybasedpermissions'));
        $articles = DBUtil::selectObjectArrayFilter('news', $where, null, null, null, '', $permChecker, null);

        foreach ($articles as $article)
        {
            $item = array(
                'title' => $article['title'],
                'text'  => $article['hometext'],
                'extra' => $article['sid'],
                'created' => $article['from'],
                'module'  => 'News',
                'session' => $sessionId
            );
            $insertResult = DBUtil::insertObject($item, 'search_result');
            if (!$insertResult) {
                return LogUtil::registerError($this->__('Error! Could not load any articles.'));
            }
        }

        return true;
    }
开发者ID:projectesIF,项目名称:Sirius,代码行数:48,代码来源:Search.php

示例9: reset

    public function reset($args) {
        // Security check
        if (!SecurityUtil::checkPermission('IWstats::', '::', ACCESS_DELETE)) {
            throw new Zikula_Exception_Forbidden();
        }

        // delete records from database
        $delete = DateUtil::getDatetime(time() - $args['deleteFromDays'] * 24 * 60 * 60);

        // get the last record in summary table
        $table = DBUtil::getTables();
        $c = $table['IWstats_column'];
        $where = "$c[datetime] < '$delete'";

        DBUtil::deleteWhere('IWstats', $where);

        // Return the id of the newly created item to the calling process
        return true;
    }
开发者ID:projectesIF,项目名称:Sirius,代码行数:19,代码来源:Admin.php

示例10: createUser

 public function createUser($user){
     if ($user) {
         $user['zk']['approved_date'] = DateUtil::getDatetime();
         $user['zk']['user_regdate'] = DateUtil::getDatetime();
         $user['zk']['approved_by'] = 2;
         DBUtil::insertObject($user['zk'], 'users', 'uid');
         $insertUserId = $user['zk']['uid'];
         $user['iw']['uid'] = $insertUserId;
         $user['iw']['suid'] = $insertUserId;
         DBUtil::insertObject($user['iw'], 'IWusers', 'suid');
         //Assignem els grups indicats en el formulari
         foreach ($user['gr'] as $grup) {
             $item = array('gid' => $grup, 'uid' => $user['zk']['uid']);
             DBUtil::insertObject($item, 'group_membership');
         }
         return $insertUserId;
     }else {
         return false;
     }
 }    
开发者ID:projectesIF,项目名称:Sirius,代码行数:20,代码来源:Listeners.php

示例11: Admin_Messages_searchapi_search

/**
 * Get all admin messages items that match the criteria
 *
 * @author Mark West, Jorn Wildt
 * @param bool args['activeonly'] only show active items
 * @return bool true/false on success/failure
 */
function Admin_Messages_searchapi_search($args)
{
    $dom = ZLanguage::getModuleDomain('Admin_Messages');
    // Security check
    if (!SecurityUtil::checkPermission('Admin_Messages::', '::', ACCESS_READ)) {
        return true;
    }
    // get the db and table info
    ModUtil::dbInfoLoad('Search');
    $pntable = DBUtil::getTables();
    $messagestable = $pntable['message'];
    $messagescolumn = $pntable['message_column'];
    $searchTable =& $pntable['search_result'];
    $searchColumn =& $pntable['search_result_column'];
    // form the where clause
    $where = '';
    if (!ModUtil::getVar('Admin_Messages', 'allowsearchinactive') || isset($args['activeonly']) && (bool) $args['activeonly']) {
        $where .= " {$messagescolumn['active']} = 1 AND ";
    }
    $where .= " ({$messagescolumn['date']}+{$messagescolumn['expire']} > '" . time() . "' OR {$messagescolumn['expire']} = 0) AND";
    $where .= search_construct_where($args, array($messagescolumn['title'], $messagescolumn['content']), $messagescolumn['language']);
    $sessionId = session_id();
    $sql = "\nSELECT\n   {$messagescolumn['mid']} as mid,\n   {$messagescolumn['title']} as title,\n   {$messagescolumn['content']} as text,\n   {$messagescolumn['date']} as date\nFROM {$messagestable}\nWHERE {$where}";
    $result = DBUtil::executeSQL($sql);
    if (!$result) {
        return LogUtil::registerError(__('Error! Could not load data.'));
    }
    $insertSql = "INSERT INTO {$searchTable}\n  ({$searchColumn['title']},\n   {$searchColumn['text']},\n   {$searchColumn['module']},\n   {$searchColumn['created']},\n   {$searchColumn['session']})\nVALUES ";
    // Process the result set and insert into search result table
    for (; !$result->EOF; $result->MoveNext()) {
        $message = $result->GetRowAssoc(2);
        if (SecurityUtil::checkPermission('Admin_Messages::', "{$message['title']}::{$message['mid']}", ACCESS_READ)) {
            $sql = $insertSql . '(' . '\'' . DataUtil::formatForStore($message['title']) . '\', ' . '\'' . DataUtil::formatForStore($message['text']) . '\', ' . '\'' . 'Admin_Messages' . '\', ' . '\'' . DataUtil::formatForStore(DateUtil::getDatetime($message['date'])) . '\', ' . '\'' . DataUtil::formatForStore($sessionId) . '\')';
            $insertResult = DBUtil::executeSQL($sql);
            if (!$insertResult) {
                return LogUtil::registerError(__('Error! Could not load data.', $dom));
            }
        }
    }
    return true;
}
开发者ID:robbrandt,项目名称:AdminMessages,代码行数:48,代码来源:pnsearchapi.php

示例12: convertAlldayStartToLocalTime

 /**
  * Converts the $obj[allDayStart] to the current timezone.
  *
  * @param array &$obj Event.
  *
  * @return void
  */
 public static function convertAlldayStartToLocalTime(&$obj)
 {
     if ($obj['allDay'] == 0) {
         if (strpos($obj['allDayStart'], ' ') !== false) {
             // calc local start time
             $time = substr($obj['allDayStart'], 0, strpos($obj['allDayStart'], ' '));
             $timezone = (int) substr($obj['allDayStart'], strpos($obj['allDayStart'], ' ') + 1);
             $timezoneCurr = (int) (UserUtil::getVar('tzoffset') !== false ? UserUtil::getVar('tzoffset') : System::getVar('timezone_offset'));
             $zoneOffset = $timezone * -1 + $timezoneCurr;
             list($hour, $min) = explode(':', $time);
             list($zone_hour, $zone_minDez) = explode('.', $zoneOffset);
             $hour += $zone_hour;
             $min += $zone_minDez * 60;
             // convert e.g. 0.75 to 45
             // more than 60 minutes than add an hour and reduce the minutes
             if ($min >= 60) {
                 $hour++;
                 $min = $min - 60;
             }
             if ($hour < 0) {
                 $obj['allDayStartLocalDateCorrection'] = -1;
                 $hour = 24 + $hour;
                 // fix minus value
             } else {
                 if ($hour > 24) {
                     $obj['allDayStartLocalDateCorrection'] = +1;
                     $hour = $hour - 24;
                     // fix to big value
                 }
             }
             $obj['allDayStartLocal'] = ($hour < 10 ? '0' : '') . $hour . ':' . ($min < 10 ? '0' : '') . $min;
         } else {
             $obj['allDayStartLocal'] = $obj['allDayStart'];
         }
         // format it
         $obj['allDayStartLocalFormated'] = DateUtil::getDatetime(strtotime($obj['startDate'] . ' ' . $obj['allDayStartLocal'] . ':00'), 'timebrief');
         // Add timezone to the time
         //$obj['allDayStartLocalFormated'] = $obj['allDayStartLocalFormated'].' '.DateUtil::strftime('%Z');
     }
 }
开发者ID:planetenkiller,项目名称:TimeIt,代码行数:47,代码来源:Util.php

示例13: setStandardFieldsOnObjectUpdate

 /**
  * Set the standard PN architecture fields to sane values for an object update.
  *
  * @param array   &$obj           The object we need to set the standard fields on.
  * @param boolean $preserveValues Whether or not to preserve value fields which have a valid value set (optional) (default=false).
  *
  * @return void
  */
 public static function setStandardFieldsOnObjectUpdate(&$obj, $preserveValues = false)
 {
     if (!is_array($obj)) {
         throw new \Exception(__f('%s called on a non-object', 'ObjectUtil::setStandardFieldsOnObjectUpdate'));
         return;
     }
     $obj['lu_date'] = isset($obj['lu_date']) && $obj['lu_date'] && $preserveValues ? $obj['lu_date'] : DateUtil::getDatetime();
     $obj['lu_uid'] = isset($obj['lu_uid']) && $obj['lu_uid'] && $preserveValues ? $obj['lu_uid'] : UserUtil::getVar('uid');
     if (is_null($obj['lu_uid'])) {
         $obj['lu_uid'] = 0;
     }
     return;
 }
开发者ID:Silwereth,项目名称:core,代码行数:21,代码来源:ObjectUtil.php

示例14: getForumsNews

public function getForumsNews($args) {
    $result = array();
    $dateTimeFrom = $args['dateTimeFrom'];
    $dateTimeTo = $args['dateTimeTo'];
    //Checking IWforums module
    $modinfo = ModUtil::getInfo(ModUtil::getIdFromName('IWforums'));
    if ($modinfo['state'] != 3) return $result;
    if ($modinfo['version'] >= '3.1.0') {
        $result = ModUtil::apiFunc('IWforums', 'user', 'getAllUnreadedMessages', array('dateTimeFrom' => $dateTimeFrom, 'dateTimeTo' => $dateTimeTo));
    } else {
        $messages = array();
        
        if (!is_null($dateTimeFrom)) {
            $pntable = DBUtil::getTables();
            $f = $pntable['IWforums_definition_column'];
            $t = $pntable['IWforums_temes_column'];
            $m = $pntable['IWforums_msg_column'];
            
            // Get all the messages posted after $dateTimeFrom in subscribibles forums
            $sql  = "SELECT F.$f[fid] AS fid,  M.$m[ftid] AS ftid, M.$m[fmid] AS fmid, M.$m[titol] AS msgTitle, M.$m[usuari] AS user, M.$m[data] AS date, M.$m[llegit] AS readers, T.$t[titol] AS topic, T.$t[order], ";
            $sql .= "F.$f[nom_forum] AS forum, F.subscriptionMode, F.subscribers, F.noSubscribers, F.$f[grup] AS grup, F.$f[mod] AS moderators ";
            $sql .= "FROM `IWforums_msg` AS M, `IWforums_temes` AS T, `IWforums_definition` AS F ";        
            $sql .= "WHERE M.$m[ftid] = T.$t[ftid] AND T.$t[fid] = F.$f[fid] AND F.$f[actiu] = 1 AND M.$m[data] >= ".$dateTimeFrom." AND M.$m[data] < ".$dateTimeTo." AND F.subscriptionMode > 0 ";
            $sql .= "ORDER BY F.$f[fid], T.$t[order], M.$m[data]";
            $query = DBUtil::executeSQL($sql);
            $messages = DBUtil::marshallObjects($query);

            foreach ($messages as $key => $message) {
                // Extract forum moderators
                $moderators = explode('$$', substr($message['moderators'], 0, strlen($message['moderators']) -1));
                unset($moderators[0]);
                //Extract message readers
                $readers = explode('$$', substr($message['readers'], 0, strlen($message['readers']) -1));
                unset($readers[0]);
                // Extract grups 
                $auxGroups = explode('$$', substr($message['grup'], 0, strlen($message['grup']) -1));
                unset($auxGroups[0]);
                $groups = array();
                foreach ($auxGroups as $ag){
                    $g = explode ('|', $ag);
                    $groups[] = $g[0];
                }
                // Construct a unique list with the users that have read access to a forum 
                $members = array();
                foreach ($groups as $group){
                    // Get group members
                    $users = UserUtil::getUsersForGroup($group);
                    foreach ($users as $user){
                        // Avoid duplicated users
                        if (!in_array($user, $members)) $members[$user] = $user;
                    }
                }
                // Add moderators
                foreach ($moderators as $moderator){
                    if (!in_array($moderator, $members)) $members[$moderator] = $moderator;
                }
                // Remove readers
                foreach ($readers as $reader) {
                    if (in_array($reader, $members)) unset($members[$reader]);                        
                }
                $messages[$key]['receivers'] = $members;
            }    
            
            // At this point, every message has a list of receivers
            // Let's construct an array with the associated information to send
            $information = array();
            foreach ($messages as $message){
                if (isset($message['receivers'])) {
                    foreach($message['receivers'] as $receiver){
                        $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
                        $information[$receiver][$message['fid']]['nom_forum'] = $message['forum'];
                        $information[$receiver][$message['fid']]['subscriptionMode'] = $message['subscriptionMode'];
                        $information[$receiver][$message['fid']]['fid'] = $message['fid'];
                        $information[$receiver][$message['fid']]['topics'][$message['ftid']]['titol'] = $message['topic'];
                        $information[$receiver][$message['fid']]['topics'][$message['ftid']]['messages'][$message['fmid']]['title'] = $message['msgTitle'];
                        $information[$receiver][$message['fid']]['topics'][$message['ftid']]['messages'][$message['fmid']]['author'] = ModUtil::func('IWmain', 'user', 'getUserInfo', array('sv' => $sv, 'info' => 'ncc', 'uid' => $message['user']));
                        $information[$receiver][$message['fid']]['topics'][$message['ftid']]['messages'][$message['fmid']]['date'] = strtolower(DateUtil::getDatetime($message['date'], 'datetimelong', true));
                    }
                }
            }
            foreach ($information as $key => $userReport){
                $view = Zikula_View::getInstance($this->name, false);  
                $view->assign('info', $userReport);
                $result[$key]['IWforums'] = $view->fetch('reports/IWforums_user_report.tpl');
            }
        }
    }
    return $result;
}
开发者ID:projectesIF,项目名称:Sirius,代码行数:89,代码来源:Cron.php

示例15: actualPostings

 /**
  *
  */
 public static function actualPostings($userid)
 {
     if (UserUtil::isLoggedIn() == true) {
         // we get a repository for users
         $userrepository = MUBoard_Util_Model::getUserRepository();
         $where = 'tbl.userid = \'' . DataUtil::formatForStore($userid) . '\'';
         $user = $userrepository->selectWhere($where);
         // we get the datetime of the last visit of muboard
         $lastVisit = $user[0]['lastVisit'];
         // we get the timestamp
         $lastVisit = $lastVisit->getTimestamp();
         // we format for
         $lastVisit = date('Y-m-d H:i:s', $lastVisit);
         $date = DateUtil::getDatetime();
         // we get a repository for postings
         $postingrepository = MUBoard_Util_Model::getPostingRepository();
         $where = 'tbl.createdDate > \'' . $lastVisit . '\'';
         $postings = $postingrepository->selectWhere($where);
         $forumids = array();
         $postingids = array();
         foreach ($postings as $posting) {
             // get forum id
             $forum = $posting->getForum();
             $forumid = $forum->getId();
             if (!in_array($forumid, $forumids)) {
                 $forumids[] = $forumid;
             }
             // get posting id
             $parent = $posting->getParent();
             if (!is_null($parent)) {
                 $parentid = $parent->getId();
                 if ($parentid != NULL) {
                     if (!in_array($parentid, $postingids)) {
                         $postingids[] = $parentid;
                     }
                 }
             } else {
                 $id = $posting->getId();
                 if (!in_array($id, $postingids)) {
                     $postingids[] = $id;
                 }
             }
         }
         //SessionUtil::setVar('muboardforumids', $forumids);
         SessionUtil::setVar('muboardpostingids', $postingids);
     }
 }
开发者ID:rmaiwald,项目名称:MUBoard,代码行数:50,代码来源:View.php


注:本文中的DateUtil::getDatetime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。