Editing the poll of given category ID, forum ID, thread ID and own ID.
@param int $cid category ID
@param int $fid forum ID
@param int $tid thread ID
@param int $pid poll ID
@return string|Response
@since 0.5
550254
public function actionEditpoll($cid = null, $fid = null, $tid = null, $pid = null)
    {
        $poll = Poll::find()->joinWith('thread')->where([
            Poll::tableName() . '.id' => $pid,
            Poll::tableName() . '.thread_id' => $tid,
            Thread::tableName() . '.category_id' => $cid,
            Thread::tableName() . '.forum_id' => $fid,
        ])->limit(1)->one();
        if (empty($poll)) {
            $this->error(Yii::t('podium/flash', 'Sorry! We can not find the poll you are looking for.'));
            return $this->redirect(['forum/index']);
        }

        if ($poll->thread->locked == 1 && !User::can(Rbac::PERM_UPDATE_THREAD, ['item' => $poll->thread])) {
            $this->info(Yii::t('podium/flash', 'This thread is locked.'));
            return $this->redirect(['forum/thread',
                'cid' => $poll->thread->forum->category->id,
                'fid' => $poll->thread->forum->id,
                'id' => $poll->thread->id,
                'slug' => $poll->thread->slug
            ]);
        }
        if ($poll->author_id != User::loggedId() && !User::can(Rbac::PERM_UPDATE_THREAD, ['item' => $poll->thread])) {
            $this->error(Yii::t('podium/flash', 'Sorry! You do not have the required permission to perform this action.'));
            return $this->redirect(['forum/thread',
                'cid' => $poll->thread->forum->category->id,
                'fid' => $poll->thread->forum->id,
                'id' => $poll->thread->id,
                'slug' => $poll->thread->slug
            ]);
        }
        if ($poll->votesCount) {
            $this->error(Yii::t('podium/flash', 'Sorry! Someone has already voted and this poll can no longer be edited.'));
            return $this->redirect(['forum/thread',
                'cid' => $poll->thread->forum->category->id,
                'fid' => $poll->thread->forum->id,
                'id' => $poll->thread->id,
                'slug' => $poll->thread->slug
            ]);
        }

        foreach ($poll->answers as $answer) {
            $poll->editAnswers[] = $answer->answer;
        }

        $postData = Yii::$app->request->post();
        if ($poll->load($postData)) {
            if ($poll->validate()) {
                if ($poll->podiumEdit()) {
                    $this->success(Yii::t('podium/flash', 'Poll has been updated.'));
                    return $this->redirect(['forum/thread',
                        'cid' => $poll->thread->forum->category->id,
                        'fid' => $poll->thread->forum->id,
                        'id' => $poll->thread->id,
                        'slug' => $poll->thread->slug
                    ]);
                }
                $this->error(Yii::t('podium/flash', 'Sorry! There was an error while updating the post. Contact administrator about this problem.'));
            }
        }
        return $this->render('editpoll', ['model' => $poll]);
    }
449125
public function lock($pid = null) {
        if ($this->isLocked($this->pidFile)) {
            return false;
        }

        $myPid = $pid ?? getmypid();
        $pidDir = dirname($this->pidFile);
        if (!is_dir($pidDir)) {
            @mkdir($pidDir, 0744, true);
        }
        file_put_contents($this->pidFile, $myPid);
        return true;
    }
829486
public function setPid($pid)
    {
        if ($this->status != self::STATUS_NEW) {
            throw new \RuntimeException('Cannot set worker pid after worker has started working');
        }

        $this->pid = (int)$pid;
    }
1013034
public static function getClientIdByUid($uid)
    {
        $gateway_data             = GatewayProtocol::$empty;
        $gateway_data['cmd']      = GatewayProtocol::CMD_GET_CLIENT_ID_BY_UID;
        $gateway_data['ext_data'] = $uid;
        $client_list              = array();
        $all_buffer_array         = self::getBufferFromAllGateway($gateway_data);
        foreach ($all_buffer_array as $local_ip => $buffer_array) {
            foreach ($buffer_array as $local_port => $connection_id_array) {
                if ($connection_id_array) {
                    foreach ($connection_id_array as $connection_id) {
                        $client_list[] = Context::addressToClientId($local_ip, $local_port, $connection_id);
                    }
                }
            }
        }
        return $client_list;
    }
685562
public function channelPermRemove($cid, $permid)
  {
    if(!is_array($permid))
    {
      $permident = (is_numeric($permid)) ? "permid" : "permsid";
    }
    else
    {
      $permident = (is_numeric(current($permid))) ? "permid" : "permsid";
    }

    $this->execute("channeldelperm", array("cid" => $cid, $permident => $permid));
  }
356723
def __get_pid_and_tid(self):
        ""
        self.dwThreadId, self.dwProcessId = \
                            win32.GetWindowThreadProcessId(self.get_handle())
254551
public static function getMenu($appid, $pid = 0) {
		$button = static::find()->where(['appid' => $appid, 'conditional' => 0, 'pid' => $pid])->select('id, type, name, key, url, media_id')->orderby('list_order, created_at')->asArray()->all();

		foreach($button as $index => $_button) {
			$button[$index]['sub_button'] = static::getMenu($appid, $_button['id']);
			unset($_button['id']);
		}

		return $button;
	}
696208
public function getLastMessageFromOtherUser($uid, $thread_id) {
    $timestamp = $this->database->query(
      'SELECT MAX(pm.created) ' .
      'FROM {private_message_thread__private_messages} pmt ' .
      'JOIN {private_messages} pm ON pmt.private_messages_target_id = pm.id ' .
      'WHERE pmt.entity_id = :thread AND pm.owner <> :uid',
      [
        ':thread' => $thread_id,
        ':uid' => $uid,
      ]
    )->fetchCol();

    // Chop of the head.
    if (is_array($timestamp)) {
      $timestamp = ($timestamp[0] !== NULL) ? $timestamp[0] : 0;
    }

    return $timestamp;
  }
1231625
public function actionForums($cid = null)
    {
        $model = Category::find()->where(['id' => $cid])->limit(1)->one();
        if (empty($model)) {
            $this->error(Yii::t('podium/flash', 'Sorry! We can not find Category with this ID.'));
            return $this->redirect(['admin/categories']);
        }
        return $this->render('forums', [
            'model' => $model,
            'categories' => Category::find()->orderBy(['sort' => SORT_ASC, 'id' => SORT_ASC])->all(),
            'forums' => Forum::find()->where(['category_id' => $model->id])->orderBy(['sort' => SORT_ASC, 'id' => SORT_ASC])->all()
        ]);
    }
607062
public function sendNotificationsReply($tid, $cur_posting, $new_pid, $post)
    {
        Container::get('hooks')->fire('model.post.send_notifications_reply_start', $tid, $cur_posting, $new_pid, $post);

        // Get the post time for the previous post in this topic
        $previous_post_time = DB::forTable('posts')
            ->select('posted')
            ->where('topic_id', $tid)
            ->order_by_desc('id');
        $previous_post_time = Container::get('hooks')->fireDB(
            'model.post.send_notifications_reply_previous',
            $previous_post_time
        );
        $previous_post_time = $previous_post_time->find_one();

        // Get any subscribed users that should be notified (banned users are excluded)
//        $result['where'] = array(
//            array('fp.read_forum' => 'IS NULL'),
//            array('fp.read_forum' => '1')
//        );
        $result['select'] = ['u.id', 'u.email', 'u.notify_with_post', 'u.language'];

        $result = DB::forTable('users')
                    ->table_alias('u')
                    ->select_many($result['select'])
                    ->inner_join(DB::prefix().'topic_subscriptions', ['u.id', '=', 's.user_id'], 's')
//                    ->left_outer_join('forum_perms', array('fp.forum_id', '=', $cur_posting['id']), 'fp', true)
//                    ->left_outer_join('forum_perms', array('fp.group_id', '=', 'u.group_id'))
            ->left_outer_join(
                DB::prefix().'forum_perms',
                '(fp.group_id=u.group_id AND fp.forum_id='. $cur_posting['id'].')',
                'fp'
            )
                    ->left_outer_join(DB::prefix().'online', ['u.id', '=', 'o.user_id'], 'o')
                    ->left_outer_join(DB::prefix().'bans', ['u.username', '=', 'b.username'], 'b')
                    ->where_raw('COALESCE(o.logged, u.last_visit)>'.$previous_post_time->posted)
                    ->where_null('b.username')
                    ->where_raw('(fp.read_forum IS NULL OR fp.read_forum=1)')
                    ->where('s.topic_id', $tid)
                    ->where_not_equal('u.id', User::get()->id);
        $result = Container::get('hooks')->fireDB('model.post.send_notifications_reply_query', $result);
        $result = $result->find_many();

        if ($result) {
            $notification_emails = [];

            $censored_message = Utils::trim(Utils::censor($post['message']));

            if (ForumSettings::get('o_censoring') == '1') {
                $cleaned_message = Container::get('email')->bbcode2email($censored_message, -1);
            } else {
                $cleaned_message = Container::get('email')->bbcode2email($post['message'], -1);
            }

            // Loop through subscribed users and send emails
            foreach ($result as $cur_subscriber) {
                // Is the subscription email for $cur_subscriber['language'] cached or not?
                if (!isset($notification_emails[$cur_subscriber['language']])) {
//                    if (file_exists(ForumEnv::get('FORUM_ROOT').'lang/'.$cur_subscriber['language'].
//                        '/mail_templates/new_reply.tpl')) {
                        $mail_tpl = Lang::getMailTemplate('new_reply')->text;
                    if ($mail_tpl) {
                        // Load the "new reply" template
//                        $mail_tpl = trim(file_get_contents(ForumEnv::get('FORUM_ROOT').'lang/'.
//                            $cur_subscriber['language'].'/mail_templates/new_reply.tpl'));
                        $mail_tpl = Container::get('hooks')->fire(
                            'model.post.send_notifications_reply_mail_tpl',
                            $mail_tpl
                        );

                        // Load the "new reply full" template (with post included)
//                        $mail_tpl_full = trim(file_get_contents(ForumEnv::get('FORUM_ROOT').'lang/'.
//                            $cur_subscriber['language'].'/mail_templates/new_reply_full.tpl'));
                        $mail_tpl_full = Lang::getMailTemplate('new_reply_full')->text;

                        $mail_tpl_full = Container::get('hooks')->fire(
                            'model.post.send_notifications_reply_mail_tpl_full',
                            $mail_tpl_full
                        );

                        // The first row contains the subject (it also starts with "Subject:")
                        $first_crlf = strpos($mail_tpl, "\n");
                        $mail_subject = trim(substr($mail_tpl, 8, $first_crlf-8));
                        $mail_subject = Container::get('hooks')->fire(
                            'model.post.send_notifications_reply_mail_subject',
                            $mail_subject
                        );
                        $mail_message = trim(substr($mail_tpl, $first_crlf));

                        $first_crlf = strpos($mail_tpl_full, "\n");
                        $mail_subject_full = trim(substr($mail_tpl_full, 8, $first_crlf-8));
                        $mail_message_full = trim(substr($mail_tpl_full, $first_crlf));

                        $mail_subject = str_replace('<topic_subject>', $cur_posting['subject'], $mail_subject);
                        $mail_message = str_replace('<topic_subject>', $cur_posting['subject'], $mail_message);
                        $mail_message = str_replace('<replier>', $post['username'], $mail_message);
                        $mail_message = str_replace(
                            '<post_url>',
                            Router::pathFor('viewPost', ['pid' => $new_pid]).'#p'.$new_pid,
                            $mail_message
                        );
                        $mail_message = str_replace(
                            '<unsubscribe_url>',
                            Router::pathFor('unsubscribeTopic', ['id' => $tid]),
                            $mail_message
                        );
                        $mail_message = str_replace(
                            '<board_mailer>',
                            ForumSettings::get('o_board_title'),
                            $mail_message
                        );
                        $mail_message = Container::get('hooks')->fire(
                            'model.post.send_notifications_reply_mail_message',
                            $mail_message
                        );

                        $mail_subject_full = str_replace(
                            '<topic_subject>',
                            $cur_posting['subject'],
                            $mail_subject_full
                        );
                        $mail_message_full = str_replace(
                            '<topic_subject>',
                            $cur_posting['subject'],
                            $mail_message_full
                        );
                        $mail_message_full = str_replace('<replier>', $post['username'], $mail_message_full);
                        $mail_message_full = str_replace('<message>', $cleaned_message, $mail_message_full);
                        $mail_message_full = str_replace(
                            '<post_url>',
                            Router::pathFor('viewPost', ['pid' => $new_pid]).'#p'.$new_pid,
                            $mail_message_full
                        );
                        $mail_message_full = str_replace(
                            '<unsubscribe_url>',
                            Router::pathFor('unsubscribeTopic', ['id' => $tid]),
                            $mail_message_full
                        );
                        $mail_message_full = str_replace(
                            '<board_mailer>',
                            ForumSettings::get('o_board_title'),
                            $mail_message_full
                        );
                        $mail_message_full = Container::get('hooks')->fire(
                            'model.post.send_notifications_reply_mail_message_full',
                            $mail_message_full
                        );

                        $notification_emails[$cur_subscriber['language']][0] = $mail_subject;
                        $notification_emails[$cur_subscriber['language']][1] = $mail_message;
                        $notification_emails[$cur_subscriber['language']][2] = $mail_subject_full;
                        $notification_emails[$cur_subscriber['language']][3] = $mail_message_full;

                        $mail_subject = $mail_message = $mail_subject_full = $mail_message_full = null;
                    }
                }

                // We have to double check here because the templates could be missing
                if (isset($notification_emails[$cur_subscriber['language']])) {
                    if ($cur_subscriber['notify_with_post'] == '0') {
                        Container::get('email')->dispatchMail(
                            $cur_subscriber['email'],
                            $notification_emails[$cur_subscriber['language']][0],
                            $notification_emails[$cur_subscriber['language']][1]
                        );
                    } else {
                        Container::get('email')->dispatchMail(
                            $cur_subscriber['email'],
                            $notification_emails[$cur_subscriber['language']][2],
                            $notification_emails[$cur_subscriber['language']][3]
                        );
                    }
                }
            }

            Container::get('hooks')->fire('model.post.send_notifications_reply');

            unset($cleaned_message);
        }
    }
1302227
public function clientMove($clid, $cid, $cpw = null)
  {
    $this->clientListReset();

    $this->execute("clientmove", array("clid" => $clid, "cid" => $cid, "cpw" => $cpw));

    if($clid instanceof Node)
    {
      $clid = $clid->getId();
    }

    if($cid instanceof Node)
    {
      $cid = $cid->getId();
    }

    if(!is_array($clid) && $clid == $this->whoamiGet("client_id"))
    {
      $this->getParent()->whoamiSet("client_channel_id", $cid);
    }
  }
612665
protected function getPageId($pid)
    {
        $pid = (int)$pid;
        if ($pid > 0) {
            return $pid;
        }
        $row = BackendUtilityCore::getRecord('tt_content', abs($pid), 'uid,pid');
        return $row['pid'];
    }
302581
public function loadById($pId)
    {
        if (! $pId instanceof Id) {
            $id = new Id($pId);
        } else {
            $id = $pId;
        }

        return $this->_loadByAttribute(static::IDFIELD, $id->getOrig());
    }
1059509
public function run($cid = null, $fid = null, $id = null, $slug = null)
    {
        $thread = $this->getThread($cid, $fid, $id, $slug);
        if (empty($thread)) {
            $this->controller->error(Yii::t('podium/flash', 'Sorry! We can not find the thread you are looking for.'));
            return $this->controller->redirect(['forum/index']);
        }

        if (!User::can($this->permission, ['item' => $thread])) {
            $this->controller->error(Yii::t('podium/flash', 'Sorry! You do not have the required permission to perform this action.'));
            return $this->controller->redirect(['forum/index']);
        }

        if (call_user_func([$thread, $this->switcher])) {
            $this->controller->success($thread->{$this->boolAttribute} ? $this->onMessage : $this->offMessage);
        } else {
            $this->controller->error(Yii::t('podium/flash', 'Sorry! There was an error while updating the thread.'));
        }
        return $this->controller->redirect([
            'forum/thread',
            'cid' => $thread->forum->category->id,
            'fid' => $thread->forum->id,
            'id' => $thread->id,
            'slug' => $thread->slug
        ]);
    }
884245
public function actionGet( $id, $cid, $fid ) {

		// Find Model
		$model	= $this->modelService->getById( $cid );

		// Update/Render if exist
		if( isset( $model ) ) {

			$file = $model->image;

			$data = [
				'mid' => $model->id, 'fid' => $file->id,
				'name' => $file->name, 'extension' => $file->extension,
				'title' => $file->title, 'caption' => $file->caption,
				'altText' => $file->altText, 'link' => $file->link, 'url' => $file->getFileUrl(),
				'description' => $file->description, 'content' => $model->content
			];

			if( $file->type == 'image' ) {

				$data[ 'mediumUrl' ]	= $file->getMediumUrl();
				$data[ 'thumbUrl' ]		= $file->getThumbUrl();
			}

			// Trigger Ajax Success
			return AjaxUtil::generateSuccess( Yii::$app->coreMessage->getMessage( CoreGlobal::MESSAGE_REQUEST ), $data );
		}

		// Trigger Ajax Failure
        return AjaxUtil::generateFailure( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_NOT_FOUND ), $errors );
	}
409437
protected function _deletePid($pid) {
		if (!$pid) {
			$pid = $this->_pid;
		}
		if (!$pid) {
			return;
		}

		$this->QueueProcesses->remove($pid);
	}
703404
public static function findByPid($intPid, array $arrOptions=array())
	{
		$t = static::$strTable;

		$arrColumns = array("$t.pid=? AND ($t.ptable='tl_elements' OR $t.ptable='')");
		
		if (!isset($arrOptions['order']))
		{
			$arrOptions['order'] = "$t.sorting";
		}

		return static::findBy($arrColumns, $intPid, $arrOptions);
	}