/**
  * Returns a list of users and/or groups matching the passed query.
  *
  * @return string
  * @xml
  */
 protected function actionGetUserByFilter()
 {
     $strFilter = $this->getParam("filter");
     $strCheckId = $this->getParam("checkid");
     $arrCheckIds = json_decode($strCheckId);
     $arrUsers = array();
     $objSource = new class_module_user_sourcefactory();
     if ($this->getParam("user") == "true") {
         $arrUsers = $objSource->getUserlistByUserquery($strFilter);
     }
     if ($this->getParam("group") == "true") {
         $arrUsers = array_merge($arrUsers, $objSource->getGrouplistByQuery($strFilter));
     }
     usort($arrUsers, function ($objA, $objB) {
         if ($objA instanceof class_module_user_user) {
             $strA = $objA->getStrUsername();
         } else {
             $strA = $objA->getStrName();
         }
         if ($objB instanceof class_module_user_user) {
             $strB = $objB->getStrUsername();
         } else {
             $strB = $objB->getStrName();
         }
         return strcmp(strtolower($strA), strtolower($strB));
     });
     $arrReturn = array();
     foreach ($arrUsers as $objOneElement) {
         if ($this->getParam("block") == "current" && $objOneElement->getSystemid() == $this->objSession->getUserID()) {
             continue;
         }
         $bitUserHasRightView = true;
         if (!empty($arrCheckIds) && is_array($arrCheckIds) && $objOneElement instanceof class_module_user_user) {
             foreach ($arrCheckIds as $strCheckId) {
                 if (!$this->hasUserViewPermissions($strCheckId, $objOneElement)) {
                     $bitUserHasRightView = false;
                     break;
                 }
             }
         }
         if ($bitUserHasRightView) {
             $arrEntry = array();
             if ($objOneElement instanceof class_module_user_user) {
                 $arrEntry["title"] = $objOneElement->getStrUsername() . " (" . $objOneElement->getStrName() . ", " . $objOneElement->getStrForename() . " )";
                 $arrEntry["label"] = $objOneElement->getStrUsername() . " (" . $objOneElement->getStrName() . ", " . $objOneElement->getStrForename() . " )";
                 $arrEntry["value"] = $objOneElement->getStrUsername() . " (" . $objOneElement->getStrName() . ", " . $objOneElement->getStrForename() . " )";
                 $arrEntry["systemid"] = $objOneElement->getSystemid();
                 $arrEntry["icon"] = class_adminskin_helper::getAdminImage("icon_user");
             } else {
                 if ($objOneElement instanceof class_module_user_group) {
                     $arrEntry["title"] = $objOneElement->getStrName();
                     $arrEntry["value"] = $objOneElement->getStrName();
                     $arrEntry["label"] = $objOneElement->getStrName();
                     $arrEntry["systemid"] = $objOneElement->getSystemid();
                     $arrEntry["icon"] = class_adminskin_helper::getAdminImage("icon_group");
                 }
             }
             $arrReturn[] = $arrEntry;
         }
     }
     class_response_object::getInstance()->setStrResponseType(class_http_responsetypes::STR_TYPE_JSON);
     return json_encode($arrReturn);
 }
예제 #2
0
/*"******************************************************************************************************
*   (c) 2004-2006 by MulchProductions, www.mulchprod.de                                                 *
*   (c) 2007-2015 by Kajona, www.kajona.de                                                              *
*       Published under the GNU LGPL v2.1, see /system/licence_lgpl.txt                                 *
********************************************************************************************************/
echo "+-------------------------------------------------------------------------------+\n";
echo "| Kajona Debug Subsystem                                                        |\n";
echo "|                                                                               |\n";
echo "| Delete all tables                                                             |\n";
echo "|                                                                               |\n";
echo "+-------------------------------------------------------------------------------+\n";
if (issetPost("dodelete")) {
    $strUsername = getPost("username");
    $strPassword = getPost("password");
    $objUsersource = new class_module_user_sourcefactory();
    $objUser = $objUsersource->getUserByUsername($strUsername);
    echo "Authenticating user...\n";
    if ($objUsersource->authenticateUser($strUsername, $strPassword)) {
        echo " ... authenticated.\n";
        $arrGroupIds = $objUser->getArrGroupIds();
        if (in_array(class_module_system_setting::getConfigValue("_admins_group_id_"), $arrGroupIds)) {
            echo "User is member of admin-group.\n";
            $arrTables = class_carrier::getInstance()->getObjDB()->getTables();
            foreach ($arrTables as $strOneTable) {
                $strQuery = "DROP TABLE " . $strOneTable;
                echo " executing " . $strQuery . "\n";
                class_carrier::getInstance()->getObjDB()->_pQuery($strQuery, array());
            }
        } else {
            echo "User is not a member of the admin-group!\n";
 /**
  * Transforms a mixed array of users and groups into a list of users.
  *
  * @param class_module_user_group[]|class_module_user_user[] $arrRecipients
  * @return class_module_user_user[]
  */
 private function getRecipientsFromArray($arrRecipients)
 {
     $arrReturn = array();
     foreach ($arrRecipients as $objOneRecipient) {
         if ($objOneRecipient instanceof class_module_user_user) {
             $arrReturn[$objOneRecipient->getStrSystemid()] = $objOneRecipient;
         } else {
             if ($objOneRecipient instanceof class_module_user_group) {
                 $objUsersources = new class_module_user_sourcefactory();
                 if ($objUsersources->getSourceGroup($objOneRecipient) != null) {
                     $arrMembers = $objUsersources->getSourceGroup($objOneRecipient)->getUserIdsForGroup();
                     foreach ($arrMembers as $strOneId) {
                         if (!isset($arrReturn[$strOneId])) {
                             $arrReturn[$strOneId] = new class_module_user_user($strOneId);
                         }
                     }
                 }
             }
         }
     }
     return $arrReturn;
 }
 /**
  * Creates a form to enter the username of the account to reset.
  *
  * @return string
  */
 private function resetForm()
 {
     $strReturn = "";
     if ($this->getParam("reset") != "" && getPost("reset") != "") {
         //try to load the user
         $objSubsystem = new class_module_user_sourcefactory();
         $objUser = $objSubsystem->getUserByUsername($this->getParam("portallogin_username"));
         if ($objUser != null) {
             $objValidator = new class_email_validator();
             if ($objUser->getStrEmail() != "" && $objValidator->validate($objUser->getStrEmail()) && $objUser->getIntPortal() == 1 && $objUser->getIntActive() == 1) {
                 //generate an authcode and save it with the user
                 $strAuthcode = generateSystemid();
                 $objUser->setStrAuthcode($strAuthcode);
                 $objUser->updateObjectToDb();
                 $strMailContent = $this->getLang("resetemailBody");
                 $strTemp = class_link::getLinkPortalHref($this->getPagename(), "", "portalResetPwd", "&authcode=" . $strAuthcode, $objUser->getSystemid());
                 $strMailContent .= html_entity_decode("<a href=\"" . $strTemp . "\">" . $strTemp . "</a>");
                 $objScriptlets = new class_scriptlet_helper();
                 $strMailContent = $objScriptlets->processString($strMailContent);
                 //create a mail confirming the change
                 $objEmail = new class_mail();
                 $objEmail->setSubject($this->getLang("resetemailTitle"));
                 $objEmail->setHtml($strMailContent);
                 $objEmail->addTo($objUser->getStrEmail());
                 $objEmail->sendMail();
                 $strReturn .= $this->getLang("resetMailSuccess");
             }
         }
     } else {
         $strTemplateID = $this->objTemplate->readTemplate("/element_portallogin/" . $this->arrElementData["portallogin_template"], "portallogin_resetform");
         $arrTemplate = array();
         $arrTemplate["portallogin_action"] = "portalLoginReset";
         $arrTemplate["portallogin_resetHint"] = "portalLoginReset";
         $arrTemplate["portallogin_elsystemid"] = $this->arrElementData["content_id"];
         $arrTemplate["action"] = class_link::getLinkPortalHref($this->getPagename());
         $strReturn .= $this->fillTemplate($arrTemplate, $strTemplateID);
     }
     return $strReturn;
 }
예제 #5
0
 /**
  * @return void
  */
 private function loadSourceObject()
 {
     if ($this->objSourceUser == null && $this->intDeleted != 1) {
         $objUsersources = new class_module_user_sourcefactory();
         $this->setObjSourceUser($objUsersources->getSourceUser($this));
     }
 }
 /**
  * Loads a group by its name, returns null of not found
  *
  * @param string $strName
  *
  * @return class_module_user_group
  */
 public static function getGroupByName($strName)
 {
     $objFactory = new class_module_user_sourcefactory();
     return $objFactory->getGroupByName($strName);
 }
예제 #7
0
 /**
  * Logs a user into the system if the credentials are correct
  * and the user is active
  *
  * @param string $strName
  * @param string $strPassword
  *
  * @return bool
  */
 public function login($strName, $strPassword)
 {
     $bitReturn = false;
     //How many users are out there with this username and being active?
     $objUsersources = new class_module_user_sourcefactory();
     try {
         if ($objUsersources->authenticateUser($strName, $strPassword)) {
             $objUser = $objUsersources->getUserByUsername($strName);
             $bitReturn = $this->internalLoginHelper($objUser);
         }
     } catch (class_authentication_exception $objEx) {
         $bitReturn = false;
     }
     if ($bitReturn === false) {
         class_logger::getInstance()->addLogRow("Unsuccessful login attempt by user " . $strName, class_logger::$levelInfo);
         class_module_user_log::generateLog(0, $strName);
     }
     return $bitReturn;
 }