public function queue_mails($args) { $cid = (int) $args['cid']; $tid = (int) $args['tid']; $pid = (int) $args['pid']; $type = $args['type']; if ($type == 'new_topic') { $subject = \CODOF\Util::get_opt('topic_notify_subject'); $message = \CODOF\Util::get_opt('topic_notify_message'); } else { $subject = \CODOF\Util::get_opt('post_notify_subject'); $message = \CODOF\Util::get_opt('post_notify_message'); } $mail = new \CODOF\Forum\Notification\Mail(); $me = CODOF\User\User::get(); $mails = array(); $offset = 0; while ($data = $this->getData($cid, $tid, $pid, $offset)) { foreach ($data as $info) { //do not send email to the user making the post if ($me->id == $info['id'] || $info['mail'] == null) { continue; } $user = array("id" => $me->id, "username" => $me->username); $post = array("omessage" => $info['omessage'], "imessage" => $info['imessage'], "url" => \CODOF\Forum\Forum::getPostURL($tid, $info['title'], $pid), "id" => $info['id'], "username" => $info['username'], "title" => $info['title'], "category" => $info['cat_name']); $mail->user = $user; $mail->post = $post; $mails[] = array("to_address" => $info['mail'], "mail_subject" => html_entity_decode($mail->replace_tokens($subject), ENT_NOQUOTES, "UTF-8"), "body" => html_entity_decode($mail->replace_tokens($message), ENT_QUOTES, "UTF-8")); } \DB::table(PREFIX . 'codo_mail_queue')->insert($mails); $offset += 400; } }
function smarty_function_match_option($params) { $user = CODOF\User\User::get(); $preference = $user->prefers($params['key']); if ($preference && $preference == $params['value']) { echo 'selected'; } }
function smarty_function_match_switch($params) { $user = CODOF\User\User::get(); $preference = $user->prefers($params['key']); if ($preference && $preference == $params['value']) { echo 'codo_switch_on'; } else { echo 'codo_switch_off'; } }
} } if ($create_account) { $reg = new CODOF\User\Register($db); $reg->mail = $mail; $reg->name = $user_profile->firstName . ' ' . $user_profile->lastName; $reg->oauth_id = $oauth_id; $reg->username = $username; $reg->avatar = $user_profile->photoURL; $reg->user_status = 1; //approved user $reg->register_user(); $reg->login(); } } header('Location: ' . CODOF\User\User::getProfileUrl()); //$adapter->logout(); } catch (Exception $e) { // In case we have errors 6 or 7, then we have to use Hybrid_Provider_Adapter::logout() to // let hybridauth forget all about the user so we can try to authenticate again. // Display the recived error, // to know more please refer to Exceptions handling section on the userguide switch ($e->getCode()) { case 0: echo "Unspecified error."; break; case 1: echo "Hybridauth configuration error."; break; case 2: echo "Provider not properly configured.";
//this user does not have an account in codoforum $reg = new \CODOF\User\Register($db); if (\CODOF\User\User::usernameExists($username)) { $username .= time(); } $reg->username = $username; $reg->name = $username; $reg->mail = $mail; $reg->user_status = 1; $ret = $reg->register_user(); $reg->login(); if (!empty($ret)) { echo "error"; } } else { CODOF\User\User::loginByMail($mail); } } }); function add_sso_js() { add_js(PLUGIN_PATH . 'sso/assets/js/sso.js', array('name' => 'sso.js', 'type' => 'defer')); add_css(PLUGIN_PATH . 'sso/assets/css/sso.css', array('name' => 'sso.css')); } //lets write the req info in divs //so that they can be fetched later using javascript function add_sso_defs($dom) { $container = $dom->getElementById('codo_js_php_defs'); $sso_token = md5(time() . CODOF\Util::get_opt('sso_secret')); $sso_client_id = CODOF\Util::get_opt('sso_client_id');
* @CODOLICENSE */ $smarty = \CODOF\Smarty\Single::get_instance(); $db = \DB::getPDO(); define('HOUR', 3600); define('DAY', HOUR * 24); define('MONTH', DAY * 30); $smarty->assign('msg', ''); $query = "SELECT * FROM " . PREFIX . "codo_config"; if (isset($_GET['t'])) { $smarty->assign('msg', 'The user has been banned successfully'); } if (isset($_POST['ban_uid']) && CODOF\Access\CSRF::valid($_POST['CSRF_token'])) { $uid = $_POST['ban_uid']; $type = $_POST['ban_type']; $user = CODOF\User\User::get(); $by = $user->username; $on = time(); $reason = $_POST['ban_reason']; $mul = array("hour" => HOUR, "day" => DAY, "month" => MONTH, "forever" => 0); $seconds = floor((int) $_POST['ban_expires'] * $mul[$_POST['ban_expires_type']]); if ($seconds == 0) { $till = 0; } else { $till = time() + (int) $seconds; } $values = array("uid" => $uid, "ban_type" => $type, "ban_by" => $by, "ban_on" => $on, "ban_reason" => $reason, "ban_expires" => $till); $ban = new CODOF\User\Ban($db); $ban->values = $values; if (isset($_POST['id'])) { $ban->update_ban($_POST['id']);
$reg->mail = $_POST['a_email']; $reg->password = $_POST['a_password']; $reg->user_status = 1; $errors = $reg->register_user(); $msg = implode('<br>', $errors); } //$msg = $errors[0]; $err = 1; $smarty->assign("msg", $msg); } } } //DELETE if (isset($_POST['delete_type']) && CODOF\Access\CSRF::valid($_POST['CSRF_token'])) { $msg = ""; $user = CODOF\User\User::get((int) $_POST['delete_id']); if ($user == false) { $_POST['delete_type'] = 'error'; $msg .= "User does not exist.<br>"; } else { if ($user->hasRoleId(ROLE_ADMIN) || $user->mail == 'anonymous@localhost') { $_POST['delete_type'] = 'error'; $msg .= "User with admin role/anonynous user cannot be deleted."; } } $smarty->assign('msg', $msg); if ($_POST['delete_type'] == 'ban_and_keep') { $user->banAccount(); } else { if ($_POST['delete_type'] == 'ban_and_delete') { $user->banAccount();
<?php /* * @CODOLICENSE */ $smarty = \CODOF\Smarty\Single::get_instance(); $db = \DB::getPDO(); CODOF\Util::get_config($db); $reg_req_admin = \CODOF\Util::get_opt('reg_req_admin'); if (isset($_POST['action']) && CODOF\Access\CSRF::valid($_POST['CSRF_token'])) { $action = $_POST['action']; if ($action == 'approve') { \DB::table(PREFIX . 'codo_users')->whereIn('id', $_POST['ids'])->update(array('user_status' => 1)); \DB::table(PREFIX . 'codo_user_roles')->whereIn('uid', $_POST['ids'])->update(array('rid' => ROLE_USER)); } else { foreach ($_POST['ids'] as $id) { $user = CODOF\User\User::get((int) $id); $user->deleteAccount(); } } } $qry = "SELECT id,username,mail,created,user_status FROM " . PREFIX . "codo_users WHERE user_status=2 OR user_status=0 AND username<>'anonymous'"; $obj = $db->query($qry); $res = $obj->fetchAll(); $users = array(); foreach ($res as $user) { $users[] = array('id' => $user['id'], 'username' => $user['username'], 'mail' => $user['mail'], 'created' => CODOF\Time::get_pretty_time($user['created']), 'confirmed' => (int) $user['user_status'] == 2 ? 'yes' : 'no'); } $smarty->assign('reg_req_admin', $reg_req_admin); $smarty->assign('users', $users); $content = $smarty->fetch('moderation/approve_users.tpl');
function smarty_modifier_get_preference($key) { $user = CODOF\User\User::get(); return $user->prefers($key); }