public function send(array $data)
 {
     $user = new sspmod_janus_User($this->_config);
     $user->setUid($data['uid']);
     $user->load();
     $to = $user->getEmail();
     $subject = '[JANUS] ' . $data['subject'];
     $body = $data['message'];
     if (!mail($to, $subject, $body, $this->_headers)) {
         throw new Exception('Could not send mail - ' . var_export($data, true));
     }
     return true;
 }
 /**
  * Retrive all entities from database
  *
  * The method retrives all entities from the database together with the
  * newest revision id.
  *
  * @param string        $subject The message title
  * @param string        $message The mesage body
  * @param arrayt|string $address Address for which the messege is sent to
  * @param int           $from    Uid of user responsible for sending the message
  *
  * @return false|array All entities from the database
  */
 public function post($subject, $message, $address, $from)
 {
     $external_messengers = $this->_config->getArray('messenger.external', array());
     // Grab the user who send the message
     $user = new sspmod_janus_User($this->_config);
     $user->setUid($from);
     $user->load();
     // and prepend the userid to the message
     $message = 'User: '******'<br />' . $message;
     $addresses = array();
     if (!is_array($address)) {
         $addresses[] = $address;
     } else {
         $addresses = $address;
     }
     foreach ($addresses as $ad) {
         $subscripers = $this->_getSubscripers($ad);
         $subscripers[] = array('uid' => '0', 'type' => 'INBOX');
         foreach ($subscripers as $subscriper) {
             $st = self::execute('INSERT INTO `' . self::$prefix . 'message`
                 (
                 `uid`, 
                 `subject`, 
                 `message`, 
                 `from`, 
                 `subscription`, 
                 `created`, 
                 `ip`
                 ) VALUES (?, ?, ?, ?, ?, ?, ?);', array($subscriper['uid'], $subject, $message, $from, $ad, date('c'), $_SERVER['REMOTE_ADDR']));
             if ($st === false) {
                 SimpleSAML_Logger::error('JANUS: Error fetching all entities');
                 return false;
             }
             if (array_key_exists($subscriper['type'], $external_messengers)) {
                 $externalconfig = $external_messengers[$subscriper['type']];
                 try {
                     $messenger = sspmod_janus_Messenger::getInstance($externalconfig['class'], $externalconfig['option']);
                     $messenger->send(array('uid' => $subscriper['uid'], 'subject' => $subject, 'message' => $message, 'from' => $from, 'address' => $ad));
                 } catch (Exception $e) {
                     SimpleSAML_Logger::error('JANUS: Error sending external message. ' . var_export($messenger, true));
                 }
             }
         }
     }
     return true;
 }
예제 #3
0
파일: history.php 프로젝트: janus-ssp/janus
$allowedUsers = $mcontroller->getUsers();
$output = '';
$securityContext = sspmod_janus_DiContainer::getInstance()->getSecurityContext();
if ((array_key_exists($userid, $allowedUsers) || $securityContext->isGranted('allentities')) && $securityContext->isGranted('entityhistory', $entity)) {
    $history_size = $mcontroller->getHistorySize();
    $history = $mcontroller->getHistory(10, $history_size);
    foreach ($history as $data) {
        $rid = $data->getRevisionid();
        $rnote = $data->getRevisionnote();
        $output .= '<section class="revision"><a href="?eid=' . $data->getEid() . '&revisionid=' . $rid . '">' . $et->t('tab_edit_entity_connection_revision') . ' ' . $rid . '</a>';
        if ($data->getRevisionid() !== $currentRevisionId) {
            $output .= ' - <a  class="janus_button" href="?compareRevision=true&amp;eid=' . $data->getEid() . '&amp;compareRevisiondid=' . $data->getRevisionid() . '&amp;revisionid=' . $currentRevisionId . '&amp;selectedtab=' . $historyTab . '">Revision history</a>';
        }
        $output .= strlen($rnote) > 80 ? ' - ' . substr($rnote, 0, 79) . '...' : ' - ' . $rnote;
        // Show edit user if present
        $user->setUid($data->getUser());
        if ($user->load()) {
            $output .= ' - ' . $user->getUserid();
        }
        $output .= ' - ' . date('Y-m-d H:i', strtotime($data->getCreated()));
        if (isset($workflowstates[$data->getWorkflow()]['name'][$et->getLanguage()])) {
            $curLang = $et->getLanguage();
        } else {
            $curLang = 'en';
        }
        if (isset($workflowstates[$data->getWorkflow()]['name'][$curLang])) {
            $output .= ' - ' . $workflowstates[$data->getWorkflow()]['name'][$curLang];
        } else {
            $output .= ' - ' . $data->getWorkflow();
        }
        $output .= '</revision>';
예제 #4
0
function editUser($params)
{
    if (empty($params['uid']) || empty($params['userid']) || !isset($params['active']) || empty($params['type'])) {
        return array('status' => 'missing_param');
    }
    if (!$params['__superuser']) {
        echo json_encode(array('status' => 'permission_denied'));
        exit;
    }
    $janus_config = sspmod_janus_DiContainer::getInstance()->getConfig();
    $uid = $params['uid'];
    $user = new sspmod_janus_User();
    $user->setUid($uid);
    $user->load(sspmod_janus_User::UID_LOAD);
    $user->setActive($params['active']);
    $user->setUserid($params['userid']);
    $user->setType($params['type']);
    $user->save();
    return array('uid' => $uid);
}
예제 #5
0
     if ($this->data['security.context']->isGranted('editsubscriptions')) {
         echo '  <a id="edit_subscription_link_' . $subscription['sid'] . '" class="janus_button" onclick="editSubscription(' . $this->data['user']->getUid() . ', ' . $subscription['sid'] . ');">' . $this->t('admin_edit') . '</a>';
     }
     echo '</td></tr>';
 }
 echo '</tbody></table>';
 if ($this->data['security.context']->isGranted('addsubscriptions')) {
     echo '<h2>' . $this->t('text_subscription_add_header') . '</h2>';
     echo '<select name="subscriptions" id="subscriptions_select">';
     echo '<option> -- ' . $this->t('tab_edit_entity_select') . ' --</option>';
     foreach ($this->data['subscriptionList'] as $subscription) {
         $tmp = explode("-", $subscription);
         if ($tmp[0] == 'USER') {
             if (isset($tmp[1]) && ctype_digit((string) $tmp[1])) {
                 $user = new sspmod_janus_User($janus_config);
                 $user->setUid($tmp[1]);
                 $user->load();
                 $name = $tmp[0] . ' - ' . $user->getUserid();
             } else {
                 if (isset($tmp[1]) && $tmp[1] == 'NEW') {
                     $name = $tmp[0] . ' - ' . 'NEW';
                 } else {
                     $name = $tmp[0];
                 }
             }
         } else {
             if ($tmp[0] == 'ENTITYUPDATE') {
                 if (isset($tmp[1]) && ctype_digit((string) $tmp[1])) {
                     $entity = new sspmod_janus_Entity($janus_config);
                     $entity->setEid($tmp[1]);
                     try {
 /**
  * Add the specified users to the entity
  *
  * @param string $eid The entity
  * @param string $uid The user to be added to the entity
  *
  * @return bool True on success and false on error
  * @since Method available since Release 1.0.0
  * @TODO Rename to addPermission or similar
  */
 public function addUserToEntity($eid, $uid)
 {
     $st = self::execute('INSERT INTO `' . self::$prefix . 'hasEntity`
             (`uid`, `eid`, `created`, `ip`)
         VALUES
             (?, ?, ?, ?);', array($uid, $eid, date('c'), $_SERVER['REMOTE_ADDR']));
     if ($st === false) {
         SimpleSAML_Logger::error('JANUS: Error fetching all entities');
         return false;
     }
     $user = new sspmod_janus_User($this->_config->getValue('store'));
     $user->setUid($uid);
     $user->load();
     $userid = $user->getUserid();
     return $userid;
 }
 /**
  * Retrive all users in the system
  *
  * The method will retrive all users in the system. NOTE this method will be
  * moved/rewritten in the future.
  *
  * @return array All users in the system
  */
 public function getUsers()
 {
     $st = $this->execute('SELECT * FROM ' . self::$prefix . 'user;');
     $rs = $st->fetchAll(PDO::FETCH_ASSOC);
     $users = array();
     foreach ($rs as $row) {
         $user = new sspmod_janus_User($this->_config->getValue('store'));
         $user->setUid($row['uid']);
         $user->load();
         $users[] = $user;
     }
     return $users;
 }
function editUser($params)
{
    if (empty($params['uid']) || empty($params['userid']) || !isset($params['active']) || empty($params['type'])) {
        return array('status' => 'missing_param');
    }
    $janus_config = SimpleSAML_Configuration::getConfig('module_janus.php');
    $uid = $params['uid'];
    $user = new sspmod_janus_User($janus_config->getValue('store'));
    $user->setUid($uid);
    $user->load(sspmod_janus_User::UID_LOAD);
    $user->setActive($params['active']);
    $user->setUserid($params['userid']);
    $user->setType($params['type']);
    $user->save();
    return array('uid' => $uid);
}
예제 #9
0
 /**
  * Retrive all users in the system
  *
  * The method will retrive all users in the system. NOTE this method will be
  * moved/rewritten in the future.
  *
  * @return array All users in the system
  */
 public function getUsers()
 {
     $st = $this->execute('SELECT * FROM ' . $this->getTablePrefix() . 'user ORDER BY `userid`;');
     $rs = $st->fetchAll(PDO::FETCH_ASSOC);
     $users = array();
     foreach ($rs as $row) {
         $user = new sspmod_janus_User();
         $user->setUid($row['uid']);
         $user->load();
         $users[] = $user;
     }
     return $users;
 }