Esempio n. 1
0
		');
        $bads = array();
        while ($row = mysql_fetch_assoc($result)) {
            $bads[] = $row;
        }
        Project::getInstance()->getSmarty()->assign('bads', $bads);
        Project::getInstance()->getSmarty()->display('../default/admin/user_bad_withdrawals.tpl');
        break;
    case 'message':
        if (isset($_REQUEST['do']) && $_REQUEST['do'] == 'send') {
            $_POST = sql_escapeArray($_POST);
            $message = new UserMessage();
            $message->setData($_POST);
            $message->user_id = intval($_REQUEST['id']);
            $message->stamp = Project::getInstance()->getNow();
            $message->save();
            location($_SERVER['PHP_SELF'] . '?action=profile&id=' . intval($_REQUEST['id']), '<p class=imp>Message <u>' . htmlspecialchars($message->title) . '</u> has been send!</p>');
        }
        Project::getInstance()->getSmarty()->assign('user_id', intval($_REQUEST['id']));
        Project::getInstance()->getSmarty()->display('../default/admin/user_message.tpl');
        break;
    default:
        $result_ips = sql_query('
			SELECT user_id, INET_NTOA(ip) as ip FROM visits GROUP BY user_id, ip
		');
        $ips = array();
        while ($row_ips = mysql_fetch_assoc($result_ips)) {
            $ips[$row_ips['user_id']][$row_ips['ip']] = '';
        }
        $users_by_ips = array();
        $users_by_ips_result = sql_query('
Esempio n. 2
0
 /**
  * Creates a new Message
  * and redirects to it.
  */
 public function actionCreate()
 {
     $userGuid = Yii::app()->request->getParam('userGuid');
     $model = new CreateMessageForm();
     // Preselect user if userGuid is given
     if ($userGuid != "") {
         $user = User::model()->findByAttributes(array('guid' => $userGuid));
         if (isset($user)) {
             $model->recipient = $user->guid;
         }
     }
     if (isset($_POST['CreateMessageForm'])) {
         $model->attributes = $_POST['CreateMessageForm'];
         if ($model->validate()) {
             // Create new Message
             $message = new Message();
             $message->title = $model->title;
             $message->save();
             // Attach Message Entry
             $messageEntry = new MessageEntry();
             $messageEntry->message_id = $message->id;
             $messageEntry->user_id = Yii::app()->user->id;
             $messageEntry->content = $model->message;
             $messageEntry->save();
             File::attachPrecreated($messageEntry, Yii::app()->request->getParam('fileUploaderHiddenGuidField'));
             // Attach also Recipients
             foreach ($model->getRecipients() as $recipient) {
                 $userMessage = new UserMessage();
                 $userMessage->message_id = $message->id;
                 $userMessage->user_id = $recipient->id;
                 $userMessage->save();
             }
             // Inform recipients (We need to add all before)
             foreach ($model->getRecipients() as $recipient) {
                 $message->notify($recipient);
             }
             // Attach User Message
             $userMessage = new UserMessage();
             $userMessage->message_id = $message->id;
             $userMessage->user_id = Yii::app()->user->id;
             $userMessage->is_originator = 1;
             $userMessage->last_viewed = new CDbExpression('NOW()');
             $userMessage->save();
             $this->htmlRedirect($this->createUrl('index', array('id' => $message->id)));
         }
     }
     $output = $this->renderPartial('create', array('model' => $model));
     Yii::app()->clientScript->render($output);
     echo $output;
 }