?> <div class="poll"> <div class="date"> <?php echo $object->getVarValue("opendate") . " - " . $object->getVarValue("closedate"); ?> </div> <div class="question"> <?php echo $object->getVarValue("question"); ?> </div> <div class="alternatives"> <? if (isAnonymous()) echo ucf(i18n("you must log in to vote")); else { ?> <form name="sPoll<?php echo $object->getNodeId(); ?> " id="sPoll<?php echo $object->getNodeId(); ?> " action="javascript:void(null);" onsubmit="Post('poll','sPoll<?php echo $object->getNodeId(); ?> ');"> <div>
function changePassword($user_id, $password) { $user = new mUser($user_id); if (($user_id == $_SESSION['murrix']['user']->id || isAdmin()) && !isAnonymous()) { $user->password = md5($password); return $user->save(); } return ucf(i18n("not enough rights to change password for"))." \"".$user->name."\""; }
function execute(&$system, $args) { if (isset($args['node_id'])) { if (isAnonymous()) { $system->addAlert(ucf(i18n("anonymous user can not vote"))); return; } if (!isset($args['answer'])) { $system->addAlert(ucf(i18n("you must choose an alternative"))); return; } $poll = new mObject($args['node_id']); if ($poll->getNodeId() > 0) { $now = time(); if (strtotime($poll->getVarValue("closedate")) < $now) { $system->addAlert(ucf(i18n("this poll is closed"))); return; } if (strtotime($poll->getVarValue("opendate")) > $now) { $system->addAlert(ucf(i18n("this poll is not open yet"))); return; } $answers = fetch("FETCH node WHERE link:node_top='".$poll->getNodeId()."' AND link:type='sub' AND property:class_name='poll_answer' AND property:name='".$_SESSION['murrix']['user']->id."' NODESORTBY property:version"); if (count($answers) > 0) { $system->addAlert(ucf(i18n("you have already voted in this poll"))); return; } $answer = new mObject(); $answer->setClassName("poll_answer"); $answer->loadVars(); $answer->name = $_SESSION['murrix']['user']->id; $answer->language = $_SESSION['murrix']['language']; $answer->rights = $poll->rights;; $answer->setVarValue("answer", $args['answer']); $answer->save(); clearNodeFileCache($poll->getNodeId()); $answer->linkWithNode($poll->getNodeId()); } } $this->draw($system, $args); }
function exec($args, $stdin, &$stdout, &$stderr, &$system) { switch ($this->stage) { case 1: $this->password1 = $args; $stdout = ucf(i18n("enter new password again:")); $system->addJSScript("document.getElementById('cmdline').type='password';"); $this->stage = 2; return false; case 2: if ($this->password1 != $args) $stdout = ucf(i18n("passwords do not match, aborting")); else { $ret = changePassword($this->user_node_id, $args); if ($ret !== true) { $stderr = $ret; $this->stage = 0; return true; } else { $user = new mUser($this->user_node_id); $stdout = ucf(i18n("successfully changed password for"))." ".$user->name; } } $this->stage = 0; return true; } if (empty($args)) $this->user_node_id = $_SESSION['murrix']['user']->id; else { $user = new mUser(); if (!$user->setByUsername($args)) { $stderr = ucf(i18n("No such user")); return true; } if (!(($user_node_id == $_SESSION['murrix']['user']->id || isAdmin()) && !isAnonymous())) { $stderr = ucf(i18n("not enough rights to change password for user")); return true; } $this->user_node_id = $user->id; } $stdout = ucf(i18n("enter new password:"******"document.getElementById('cmdline').type='password';"); $this->stage = 1; return false; }
function exec($args, $stdin, &$stdout, &$stderr, &$system) { if (isAnonymous()) { $stderr = ucf(i18n("anonymous user can not send messages")); return true; } switch ($this->stage) { case 1: $this->username = $args; $stdout = "$args\n"; $stdout .= ucf(i18n("subject:")); $this->stage = 2; return false; case 2: $this->subject = $args; $stdout = "$args\n".ucf(i18n("message:")); $this->stage = 3; return false; case 3: $this->message = $args; $stdout = "$args\n".ucf(i18n("attachment:")); $this->stage = 4; return false; case 4: $this->attachment = $args; $stdout = "$args\n".ucf(i18n("are you sure you want to send message"))." (Y/n)?"; $this->stage = 5; return false; case 5: if (empty($args) || strtolower($args) == "y" || strtolower($args) == "yes") { $user = new mUser(); $user->setByUsername($this->username); if ($user->id <= 0) { $stderr = ucf(i18n("no such user"))." - ".$this->username; $this->stage = 0; return true; } if (!$user->sendMessage($this->subject, $this->message, $this->attachment)) { $stderr = ucf(i18n("failed to send message")); $this->stage = 0; return true; } $stdout = ucf(i18n("sent message successfully")); $this->stage = 0; return true; } $stdout = ucf(i18n("aborted by user")); $this->stage = 0; return true; } if (empty($args)) { $stdout = ucf(i18n("to:")); $this->stage = 1; } else { $this->username = $args; $stdout .= ucf(i18n("subject:")); $this->stage = 2; } return false; }