/** * Marks action items as completed * * @param string $type Item type * @param array $uids User IDs * @param string $component ITem component * @param unknown $element Parameter description (if any) ... * @return boolean True if no errors */ public function onTakeAction($type, $uids = array(), $component = '', $element = null) { // Do we have the proper bits? if (!$element || !$component || !$type) { return false; } // Do we have any user IDs? if (count($uids) > 0) { $database = App::get('db'); // Loop through each ID foreach ($uids as $uid) { // Find any actions the user needs to take for this $component and $element $mids = Hubzero\Message\Action::getActionItems($type, $component, $element, $uid); // Check if the user has any action items if (count($mids) > 0) { foreach ($mids as $mid) { $xseen = Hubzero\Message\Seen::oneByMessageAndUser($mid, $uid); if ($xseen->get('whenseen') == '' || $xseen->get('whenseen') == $database->getNullDate() || $xseen->get('whenseen') == NULL) { $xseen->set('whenseen', Date::toSql()); $xseen->save(); } } } } } return true; }
/** * Mark messages as read * * @param object $database JDatabase * @param string $option Name of the component * @param object $member Current member * @return void */ public function markasread($database, $option, $member) { $limit = Request::getInt('limit', Config::get('list_limit')); $start = Request::getInt('limitstart', 0); $ids = Request::getVar('mid', array()); if (count($ids) > 0) { // Check for request forgeries Request::checkToken(['get', 'post']); foreach ($ids as $mid) { $xseen = new \Hubzero\Message\Seen($database); $xseen->mid = $mid; $xseen->uid = $member->get('uidNumber'); //$xseen->loadRecord(); if ($xseen->whenseen == '' || $xseen->whenseen == $database->getNullDate() || $xseen->whenseen == NULL) { $xseen->whenseen = Date::toSql(); $xseen->store(true); } } $this->addPluginMessage('You have successfully marked <b><u>' . count($ids) . '</u></b> message(s) as read.', 'passed'); } else { $this->addPluginMessage("No messages selected.", "warning"); } return App::redirect(Route::url($member->getLink() . '&active=messages&task=' . Request::getWord('activetab', 'inbox') . '&start=' . $start . '&limit=' . $limit)); }